public static function recreate($typeName, $values)
    {
        $db = static::getDb();
        $quotedType = $db->quoteColumnName($typeName);

        $transaction = $db->beginTransaction();
        try {
            $columns = static::columns($typeName);

            do {
                $tmpTypeName = md5(rand());
            } while (static::exists($tmpTypeName));

            static::rename($typeName, $tmpTypeName);
            static::create($typeName, $values);

            $schema = $db->getSchema();
            foreach ($columns as $column) {
                $quotedColumn = $db->quoteColumnName($column['column_name']);
                $db->createCommand(
                    'ALTER TABLE ' . $db->quoteTableName($column['table_name'])
                    . ' ALTER ' . $quotedColumn
                    . ' TYPE ' . $quotedType
                    . ' USING ' . $quotedColumn . '::text::' . $quotedType
                )->execute();
                $schema->refreshTableSchema($column['table_name']);
            }

            static::drop($tmpTypeName);

            $transaction->commit();
        } catch (\Exception $e) {
            $transaction->rollBack();
            throw $e;
        }
    }
public static function recreate($typeName, $values)
    {
        $db = static::getDb();
        $quotedType = $db->quoteColumnName($typeName);

        $transaction = $db->beginTransaction();
        try {
            $columns = static::columns($typeName);

            do {
                $tmpTypeName = md5(rand());
            } while (static::exists($tmpTypeName));

            static::rename($typeName, $tmpTypeName);
            static::create($typeName, $values);

            $schema = $db->getSchema();
            foreach ($columns as $column) {
                $quotedColumn = $db->quoteColumnName($column['column_name']);
                $db->createCommand(
                    'ALTER TABLE ' . $db->quoteTableName($column['table_name'])
                    . ' ALTER ' . $quotedColumn
                    . ' TYPE ' . $quotedType
                    . ' USING ' . $quotedColumn . '::text::' . $quotedType
                )->execute();
                $schema->refreshTableSchema($column['table_name']);
            }

            static::drop($tmpTypeName);

            $transaction->commit();
        } catch (\Exception $e) {
            $transaction->rollBack();
            throw $e;
        }
    }
public static function recreate ( $ typeName , $ values ) { $ db = static :: getDb ( ) ; $ quotedType = $ db -> quoteColumnName ( $ typeName ) ; $ transaction = $ db -> beginTransaction ( ) ; try { $ columns = static :: columns ( $ typeName ) ; do { $ tmpTypeName = md5 ( rand ( ) ) ; } while ( static :: exists ( $ tmpTypeName ) ) ; static :: rename ( $ typeName , $ tmpTypeName ) ; static :: create ( $ typeName , $ values ) ; $ schema = $ db -> getSchema ( ) ; foreach ( $ columns as $ column ) { $ quotedColumn = $ db -> quoteColumnName ( $ column [ 'column_name' ] ) ; $ db -> createCommand ( 'ALTER TABLE ' . $ db -> quoteTableName ( $ column [ 'table_name' ] ) . ' ALTER ' . $ quotedColumn . ' TYPE ' . $ quotedType . ' USING ' . $ quotedColumn . '::text::' . $ quotedType ) -> execute ( ) ; $ schema -> refreshTableSchema ( $ column [ 'table_name' ] ) ; } static :: drop ( $ tmpTypeName ) ; $ transaction -> commit ( ) ; } catch ( \ Exception $ e ) { $ transaction -> rollBack ( ) ; throw $ e ; } }
Try to recreate an enum type with new values

@param string $typeName name of the enum type
@param string[] $values new values of the enum type
@throws \Exception
Try to recreate an enum type with new values