Skip to content

Commit d0415fb

Browse files
committed
Fix bug and failing tests
1 parent 7d557c4 commit d0415fb

20 files changed

+34
-9
lines changed

src/lib/migrations/PostgresMigrationBuilder.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,6 @@ public function handleCommentsMigration()
266266
if ($column->comment) {
267267
$this->migration
268268
->addUpCode($this->recordBuilder->addCommentOnColumn($tableAlias, $column->name, $column->comment));
269-
} else {
270-
$this->migration
271-
->addUpCode($this->recordBuilder->dropCommentOnColumn($tableAlias, $column->name))
272-
;
273269
}
274270
}
275271
}

tests/specs/blog/migrations_pgsql_db/m200000_000002_create_table_blog_posts.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function safeUp()
2121
$this->createIndex('blog_posts_slug_key', '{{%blog_posts}}', 'slug', true);
2222
$this->addForeignKey('fk_blog_posts_category_id_categories_id', '{{%blog_posts}}', 'category_id', '{{%categories}}', 'id');
2323
$this->addForeignKey('fk_blog_posts_created_by_id_users_id', '{{%blog_posts}}', 'created_by_id', '{{%users}}', 'id');
24+
$this->addCommentOnColumn('{{%blog_posts}}', 'category_id', 'Category of posts');
25+
$this->addCommentOnColumn('{{%blog_posts}}', 'created_by_id', 'The User');
2426
}
2527

2628
public function safeDown()

tests/specs/blog/migrations_pgsql_db/m200000_000004_create_table_post_comments.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public function safeUp()
1717
]);
1818
$this->addForeignKey('fk_post_comments_post_id_blog_posts_uid', '{{%post_comments}}', 'post_id', '{{%blog_posts}}', 'uid');
1919
$this->addForeignKey('fk_post_comments_author_id_users_id', '{{%post_comments}}', 'author_id', '{{%users}}', 'id');
20+
$this->addCommentOnColumn('{{%post_comments}}', 'post_id', 'A blog post (uid used as pk for test purposes)');
21+
$this->addCommentOnColumn('{{%post_comments}}', 'author_id', 'The User');
2022
}
2123

2224
public function safeDown()

tests/specs/blog_v2/migrations_maria_db/m200000_000000_change_table_v2_posts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public function up()
1010
$this->addColumn('{{%v2_posts}}', 'id', $this->bigPrimaryKey());
1111
$this->addColumn('{{%v2_posts}}', 'lang', 'enum("ru", "eng") NULL DEFAULT \'ru\' AFTER slug');
1212
$this->dropColumn('{{%v2_posts}}', 'uid');
13-
$this->alterColumn('{{%v2_posts}}', 'category_id', $this->bigInteger()->notNull());
13+
$this->alterColumn('{{%v2_posts}}', 'category_id', $this->bigInteger()->notNull()->comment('Category of posts'));
1414
$this->alterColumn('{{%v2_posts}}', 'active', $this->tinyInteger(1)->notNull());
15-
$this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->null()->defaultValue(null));
15+
$this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->null()->defaultValue(null)->comment('The User'));
1616
$this->dropIndex('v2_posts_slug_key', '{{%v2_posts}}');
1717
}
1818

tests/specs/blog_v2/migrations_maria_db/m200000_000005_change_table_v2_comments.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function up()
1111
$this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');
1212
$this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->null()->defaultValue(null)->after('post_id')->comment('The User'));
1313
$this->dropColumn('{{%v2_comments}}', 'author_id');
14+
$this->alterColumn('{{%v2_comments}}', 'post_id', $this->bigInteger(20)->notNull()->comment('A blog post (uid used as pk for test purposes)'));
1415
$this->alterColumn('{{%v2_comments}}', 'message', $this->text()->notNull());
1516
$this->alterColumn('{{%v2_comments}}', 'meta_data', $this->string(300)->null()->defaultValue(''));
1617
$this->alterColumn('{{%v2_comments}}', 'created_at', $this->timestamp()->notNull());
@@ -25,6 +26,7 @@ public function down()
2526
$this->alterColumn('{{%v2_comments}}', 'created_at', $this->integer(11)->notNull());
2627
$this->alterColumn('{{%v2_comments}}', 'meta_data', 'json NOT NULL DEFAULT \'[]\'');
2728
$this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL DEFAULT \'[]\'');
29+
$this->alterColumn('{{%v2_comments}}', 'post_id', $this->bigInteger(20)->notNull());
2830
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer(11)->notNull());
2931
$this->dropColumn('{{%v2_comments}}', 'user_id');
3032
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');

tests/specs/blog_v2/migrations_mysql_db/m200000_000000_change_table_v2_posts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public function up()
1010
$this->addColumn('{{%v2_posts}}', 'id', $this->bigPrimaryKey());
1111
$this->addColumn('{{%v2_posts}}', 'lang', 'enum("ru", "eng") NULL DEFAULT \'ru\' AFTER slug');
1212
$this->dropColumn('{{%v2_posts}}', 'uid');
13-
$this->alterColumn('{{%v2_posts}}', 'category_id', $this->bigInteger()->notNull());
13+
$this->alterColumn('{{%v2_posts}}', 'category_id', $this->bigInteger()->notNull()->comment('Category of posts'));
1414
$this->alterColumn('{{%v2_posts}}', 'active', $this->tinyInteger(1)->notNull());
15-
$this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->null()->defaultValue(null));
15+
$this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->null()->defaultValue(null)->comment('The User'));
1616
$this->dropIndex('v2_posts_slug_key', '{{%v2_posts}}');
1717
}
1818

tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function up()
1111
$this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');
1212
$this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->null()->defaultValue(null)->after('post_id')->comment('The User'));
1313
$this->dropColumn('{{%v2_comments}}', 'author_id');
14+
$this->alterColumn('{{%v2_comments}}', 'post_id', $this->bigInteger()->notNull()->comment('A blog post (uid used as pk for test purposes)'));
1415
$this->alterColumn('{{%v2_comments}}', 'message', $this->text()->notNull());
1516
$this->alterColumn('{{%v2_comments}}', 'meta_data', $this->string(300)->null()->defaultValue(''));
1617
$this->alterColumn('{{%v2_comments}}', 'created_at', $this->timestamp()->notNull());
@@ -25,6 +26,7 @@ public function down()
2526
$this->alterColumn('{{%v2_comments}}', 'created_at', $this->integer()->notNull());
2627
$this->alterColumn('{{%v2_comments}}', 'meta_data', 'json NOT NULL');
2728
$this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL');
29+
$this->alterColumn('{{%v2_comments}}', 'post_id', $this->bigInteger()->notNull());
2830
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull());
2931
$this->dropColumn('{{%v2_comments}}', 'user_id');
3032
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');

tests/specs/blog_v2/migrations_pgsql_db/m200000_000000_change_table_v2_posts.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ public function safeUp()
1212
$this->addColumn('{{%v2_posts}}', 'lang', '"enum_itt_v2_posts_lang" NULL DEFAULT \'ru\'');
1313
$this->dropColumn('{{%v2_posts}}', 'uid');
1414
$this->alterColumn('{{%v2_posts}}', 'category_id', 'int8 NOT NULL USING "category_id"::int8');
15+
$this->addCommentOnColumn('{{%v2_posts}}', 'category_id', 'Category of posts');
1516
$this->alterColumn('{{%v2_posts}}', 'active', "DROP DEFAULT");
1617
$this->alterColumn('{{%v2_posts}}', 'created_by_id', 'int8 NULL USING "created_by_id"::int8');
18+
$this->addCommentOnColumn('{{%v2_posts}}', 'created_by_id', 'The User');
1719
$this->dropIndex('v2_posts_slug_key', '{{%v2_posts}}');
1820
}
1921

2022
public function safeDown()
2123
{
2224
$this->createIndex('v2_posts_slug_key', '{{%v2_posts}}', 'slug', true);
25+
$this->dropCommentFromColumn('{{%v2_posts}}', 'created_by_id');
2326
$this->alterColumn('{{%v2_posts}}', 'created_by_id', 'int4 NULL USING "created_by_id"::int4');
27+
$this->dropCommentFromColumn('{{%v2_posts}}', 'category_id');
2428
$this->alterColumn('{{%v2_posts}}', 'category_id', 'int4 NOT NULL USING "category_id"::int4');
2529
$this->addColumn('{{%v2_posts}}', 'uid', $this->bigInteger()->notNull());
2630
$this->dropColumn('{{%v2_posts}}', 'lang');

tests/specs/blog_v2/migrations_pgsql_db/m200000_000005_change_table_v2_comments.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function safeUp()
1111
$this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');
1212
$this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->null()->defaultValue(null)->comment('The User'));
1313
$this->dropColumn('{{%v2_comments}}', 'author_id');
14+
$this->addCommentOnColumn('{{%v2_comments}}', 'post_id', 'A blog post (uid used as pk for test purposes)');
1415
$this->alterColumn('{{%v2_comments}}', 'message', 'text NOT NULL USING "message"::text');
1516
$this->alterColumn('{{%v2_comments}}', 'message', "DROP DEFAULT");
1617
$this->alterColumn('{{%v2_comments}}', 'meta_data', 'varchar(300) NULL USING "meta_data"::varchar');
@@ -28,6 +29,7 @@ public function safeDown()
2829
$this->alterColumn('{{%v2_comments}}', 'created_at', 'int4 NOT NULL USING "created_at"::int4');
2930
$this->alterColumn('{{%v2_comments}}', 'meta_data', 'jsonb NOT NULL USING "meta_data"::jsonb');
3031
$this->alterColumn('{{%v2_comments}}', 'message', 'jsonb NOT NULL USING "message"::jsonb');
32+
$this->dropCommentFromColumn('{{%v2_comments}}', 'post_id');
3133
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull());
3234
$this->dropColumn('{{%v2_comments}}', 'user_id');
3335
$this->alterColumn('{{%v2_comments}}', 'message', "SET DEFAULT '[]'");

tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000001_create_table_fruits.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public function safeUp()
1212
'name' => $this->text()->null()->defaultValue(null)->comment('desc'),
1313
0 => '"description" double precision NULL DEFAULT NULL',
1414
]);
15-
$this->dropCommentFromColumn('{{%fruits}}', 'id');
1615
$this->addCommentOnColumn('{{%fruits}}', 'name', 'desc');
1716
$this->addCommentOnColumn('{{%fruits}}', 'description', 'desc 2');
1817
}

tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000001_create_table_b123s.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function safeUp()
1313
'c123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
1414
]);
1515
$this->addForeignKey('fk_b123s_c123_id_c123s_id', '{{%b123s}}', 'c123_id', '{{%c123s}}', 'id');
16+
$this->addCommentOnColumn('{{%b123s}}', 'c123_id', 'desc');
1617
}
1718

1819
public function safeDown()

tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000002_create_table_a123s.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function safeUp()
1313
'b123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
1414
]);
1515
$this->addForeignKey('fk_a123s_b123_id_b123s_id', '{{%a123s}}', 'b123_id', '{{%b123s}}', 'id');
16+
$this->addCommentOnColumn('{{%a123s}}', 'b123_id', 'desc');
1617
}
1718

1819
public function safeDown()

tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000003_create_table_accounts.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function safeUp()
1111
'id' => $this->primaryKey(),
1212
'name' => $this->string(40)->notNull()->comment('account name'),
1313
]);
14+
$this->addCommentOnColumn('{{%accounts}}', 'name', 'account name');
1415
}
1516

1617
public function safeDown()

tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000005_create_table_domains.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public function safeUp()
1414
0 => '"created_at" timestamp NOT NULL',
1515
]);
1616
$this->addForeignKey('fk_domains_account_id_accounts_id', '{{%domains}}', 'account_id', '{{%accounts}}', 'id');
17+
$this->addCommentOnColumn('{{%domains}}', 'name', 'domain or sub-domain name, in DNS syntax, IDN are converted');
18+
$this->addCommentOnColumn('{{%domains}}', 'account_id', 'user account');
1719
}
1820

1921
public function safeDown()

tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000006_create_table_e123s.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function safeUp()
1313
'b123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
1414
]);
1515
$this->addForeignKey('fk_e123s_b123_id_b123s_id', '{{%e123s}}', 'b123_id', '{{%b123s}}', 'id');
16+
$this->addCommentOnColumn('{{%e123s}}', 'b123_id', 'desc');
1617
}
1718

1819
public function safeDown()

tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000007_create_table_routings.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public function safeUp()
2121
$this->addForeignKey('fk_routings_domain_id_domains_id', '{{%routings}}', 'domain_id', '{{%domains}}', 'id');
2222
$this->addForeignKey('fk_routings_d123_id_d123s_id', '{{%routings}}', 'd123_id', '{{%d123s}}', 'id');
2323
$this->addForeignKey('fk_routings_a123_id_a123s_id', '{{%routings}}', 'a123_id', '{{%a123s}}', 'id');
24+
$this->addCommentOnColumn('{{%routings}}', 'domain_id', 'domain');
25+
$this->addCommentOnColumn('{{%routings}}', 'd123_id', 'desc');
26+
$this->addCommentOnColumn('{{%routings}}', 'a123_id', 'desc');
2427
}
2528

2629
public function safeDown()

tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function safeUp()
2121
9 => '"col_11" text NULL DEFAULT NULL',
2222
10 => '"price" decimal(10,2) NULL DEFAULT 0',
2323
]);
24+
$this->addCommentOnColumn('{{%pristines}}', 'price', 'price in EUR');
2425
}
2526

2627
public function safeDown()

tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function safeUp()
2121
9 => '"col_11" text NULL DEFAULT NULL',
2222
10 => '"price" decimal(10,2) NULL DEFAULT 0',
2323
]);
24+
$this->addCommentOnColumn('{{%pristines}}', 'price', 'price in EUR');
2425
}
2526

2627
public function safeDown()

tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function safeUp()
2121
9 => '"col_11" text NULL DEFAULT NULL',
2222
10 => '"price" decimal(10,2) NULL DEFAULT 0',
2323
]);
24+
$this->addCommentOnColumn('{{%pristines}}', 'price', 'price in EUR');
2425
}
2526

2627
public function safeDown()

tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000001_create_table_postxes.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public function safeUp()
1919
$this->addForeignKey('fk_postxes_user_2_id_userxes_id', '{{%postxes}}', 'user_2_id', '{{%userxes}}', 'id', 'SET NULL', 'CASCADE');
2020
$this->addForeignKey('fk_postxes_user_3_id_userxes_id', '{{%postxes}}', 'user_3_id', '{{%userxes}}', 'id', 'SET NULL');
2121
$this->addForeignKey('fk_postxes_user_4_id_userxes_id', '{{%postxes}}', 'user_4_id', '{{%userxes}}', 'id');
22+
$this->addCommentOnColumn('{{%postxes}}', 'user_id', 'x on-x (update|delete) foreign key constraint');
23+
$this->addCommentOnColumn('{{%postxes}}', 'user_2_id', 'x on-x (update|delete) foreign key constraint');
24+
$this->addCommentOnColumn('{{%postxes}}', 'user_3_id', 'x on-x (update|delete) foreign key constraint');
25+
$this->addCommentOnColumn('{{%postxes}}', 'user_4_id', 'x on-x (update|delete) foreign key constraint');
2226
}
2327

2428
public function safeDown()

0 commit comments

Comments
 (0)