public static function remove($typeName, $values, $updateTables = false)
    {
        $values = (array) $values;

        $db = static::getDb();
        $transaction = $db->beginTransaction();
        try {
            $allValues = static::values($typeName);
            $removedValues = [];

            $isAssociative = ArrayHelper::isAssociative($values, false);
            if ($isAssociative) {
                $caseQuery = '';
                $placeholders = [];
                $phIndex = 0;
                foreach ($values as $k => $v) {
                    $ph1 = 'case' . $phIndex++;
                    $ph2 = 'case' . $phIndex++;
                    if (is_int($k)) {
                        $removedValues[] = $v;
                    } else {
                        $removedValues[] = $k;
                        $placeholders[$ph1] = $k;
                        $placeholders[$ph2] = $v;
                        if (!in_array($v, $allValues)) {
                            static::add($typeName, $v);
                            $allValues[] = $v;
                        }
                        $caseQuery .= ' WHEN :' . $ph1 . ' THEN :' . $ph2;
                    }
                }

                $caseQuery .= ' ELSE NULL END::' . $db->quoteColumnName($typeName);
            } else {
                $removedValues = $values;
            }

            if ($updateTables) {
                $columns = static::columns($typeName);
                foreach ($columns as $column) {
                    $columnName = $column['column_name'];
                    $value = $isAssociative
                        ? new Expression('CASE ' . $db->quoteColumnName($columnName) . $caseQuery, $placeholders)
                        : null;
                    $db->createCommand()
                        ->update($column['table_name'], [$columnName => $value], [$columnName => $removedValues])
                        ->execute();
                }
            }

            static::recreate($typeName, array_diff($allValues, $removedValues));

            $transaction->commit();
        } catch (\Exception $e) {
            $transaction->rollBack();
            throw $e;
        }
    }