Skip to content

Commit d0415fb

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

File tree

20 files changed

+34
-9
lines changed

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
}

0 commit comments

Comments
 (0)