Skip to content

Commit d5c2c28

Browse files
committed
Handle column position in case of dropping a column (in down code -> add column) (for one or more columns) + Fix failing tests
1 parent 79bc270 commit d5c2c28

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

tests/specs/blog_v2/migrations_maria_db/m200000_000004_change_table_v2_users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function down()
2525
$this->alterColumn('{{%v2_users}}', 'created_at', $this->timestamp()->null()->defaultExpression("current_timestamp()"));
2626
$this->alterColumn('{{%v2_users}}', 'role', $this->string(20)->null()->defaultValue('reader'));
2727
$this->alterColumn('{{%v2_users}}', 'email', $this->string(200)->notNull());
28-
$this->addColumn('{{%v2_users}}', 'username', $this->string(200)->notNull());
28+
$this->addColumn('{{%v2_users}}', 'username', $this->string(200)->notNull()->after('id'));
2929
$this->dropColumn('{{%v2_users}}', 'login');
3030
}
3131
}

tests/specs/blog_v2/migrations_maria_db/m200000_000005_change_table_v2_comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function down()
2525
$this->alterColumn('{{%v2_comments}}', 'created_at', $this->integer(11)->notNull());
2626
$this->alterColumn('{{%v2_comments}}', 'meta_data', 'json NOT NULL DEFAULT \'[]\'');
2727
$this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL DEFAULT \'[]\'');
28-
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer(11)->notNull());
28+
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer(11)->notNull()->after('post_id'));
2929
$this->dropColumn('{{%v2_comments}}', 'user_id');
3030
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');
3131
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'uid', 'v2_posts', 'post_id');

tests/specs/blog_v2/migrations_mysql_db/m200000_000004_change_table_v2_users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function down()
2525
$this->alterColumn('{{%v2_users}}', 'created_at', $this->timestamp()->null()->defaultExpression("CURRENT_TIMESTAMP"));
2626
$this->alterColumn('{{%v2_users}}', 'role', $this->string(20)->null()->defaultValue('reader'));
2727
$this->alterColumn('{{%v2_users}}', 'email', $this->string(200)->notNull());
28-
$this->addColumn('{{%v2_users}}', 'username', $this->string(200)->notNull());
28+
$this->addColumn('{{%v2_users}}', 'username', $this->string(200)->notNull()->after('id'));
2929
$this->dropColumn('{{%v2_users}}', 'login');
3030
}
3131
}

tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function down()
2525
$this->alterColumn('{{%v2_comments}}', 'created_at', $this->integer()->notNull());
2626
$this->alterColumn('{{%v2_comments}}', 'meta_data', 'json NOT NULL');
2727
$this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL');
28-
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull());
28+
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull()->after('post_id'));
2929
$this->dropColumn('{{%v2_comments}}', 'user_id');
3030
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');
3131
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'uid', 'v2_posts', 'post_id');

tests/specs/change_column_name/maria/app/migrations_maria_db/m200000_000000_change_table_column_name_changes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function up()
1313

1414
public function down()
1515
{
16-
$this->addColumn('{{%column_name_changes}}', 'updated_at', $this->datetime()->notNull());
16+
$this->addColumn('{{%column_name_changes}}', 'updated_at', $this->datetime()->notNull()->after('name'));
1717
$this->dropColumn('{{%column_name_changes}}', 'updated_at_2');
1818
}
1919
}

tests/specs/change_column_name/mysql/app/migrations_mysql_db/m200000_000000_change_table_column_name_changes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function up()
1313

1414
public function down()
1515
{
16-
$this->addColumn('{{%column_name_changes}}', 'updated_at', $this->datetime()->notNull());
16+
$this->addColumn('{{%column_name_changes}}', 'updated_at', $this->datetime()->notNull()->after('name'));
1717
$this->dropColumn('{{%column_name_changes}}', 'updated_at_2');
1818
}
1919
}

tests/specs/enum/new_column/maria/app/migrations_maria_db/m200000_000001_change_table_newcolumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414

1515
public function down()
1616
{
17-
$this->addColumn('{{%newcolumns}}', 'delete_col', 'enum("FOUR", "FIVE", "SIX") NULL DEFAULT NULL');
17+
$this->addColumn('{{%newcolumns}}', 'delete_col', 'enum("FOUR", "FIVE", "SIX") NULL DEFAULT NULL AFTER id');
1818
$this->dropColumn('{{%newcolumns}}', 'new_column_x');
1919
$this->dropColumn('{{%newcolumns}}', 'new_column');
2020
}

tests/specs/enum/new_column/mysql/app/migrations_mysql_db/m200000_000001_change_table_newcolumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414

1515
public function down()
1616
{
17-
$this->addColumn('{{%newcolumns}}', 'delete_col', 'enum("FOUR", "FIVE", "SIX") NULL DEFAULT NULL');
17+
$this->addColumn('{{%newcolumns}}', 'delete_col', 'enum("FOUR", "FIVE", "SIX") NULL DEFAULT NULL AFTER id');
1818
$this->dropColumn('{{%newcolumns}}', 'new_column_x');
1919
$this->dropColumn('{{%newcolumns}}', 'new_column');
2020
}

0 commit comments

Comments
 (0)