yii2-openapi icon indicating copy to clipboard operation
yii2-openapi copied to clipboard

Order of migration statement is incorrect when one PK column is deleted and new one is created

Open SOHELAHMED7 opened this issue 2 years ago • 0 comments

See file : yii2-openapi/tests/specs/blog_v2/migrations_pgsql_db/m200000_000000_change_table_v2_posts.php

// after deleting uid this should be executed,
// currently getting error about 2 PK in one table
$this->addColumn('{{%v2_posts}}', 'id', $this->bigPrimaryKey());
$this->execute('CREATE TYPE "enum_itt_v2_posts_lang" AS ENUM(\'ru\', \'eng\')');
$this->addColumn('{{%v2_posts}}', 'lang', '"enum_itt_v2_posts_lang" NULL DEFAULT \'ru\'');
// below should be deleted first
$this->dropColumn('{{%v2_posts}}', 'uid');

Order is incorrect. First previous ID should be deleted. Then new one should be created. This result in failing migration.


priority: very low (as ID column once created are not often deleted)

type: enhancemnet

SOHELAHMED7 avatar Jun 01 '23 10:06 SOHELAHMED7