@@ -53,6 +53,9 @@ defmodule Ecto.Integration.MigrationTest do
5353
5454 add :from_default_to_no_default , :integer , default: 0
5555 add :from_no_default_to_default , :integer
56+
57+ add :another_from_default_to_no_default , :integer , default: 0
58+ add :another_from_no_default_to_default , :integer
5659 end
5760
5861 alter table ( :alter_col_migration ) do
@@ -62,6 +65,9 @@ defmodule Ecto.Integration.MigrationTest do
6265
6366 modify :from_default_to_no_default , :integer , default: nil
6467 modify :from_no_default_to_default , :integer , default: 0
68+
69+ modify :another_from_default_to_no_default , :integer , default: nil , from: { :integer , default: 0 }
70+ modify :another_from_no_default_to_default , :integer , default: 0 , from: { :integer , default: nil }
6571 end
6672
6773 execute "INSERT INTO alter_col_migration (from_null_to_not_null, another_from_null_to_not_null) VALUES ('foo', 'baz')"
@@ -143,7 +149,7 @@ defmodule Ecto.Integration.MigrationTest do
143149 end
144150
145151 alter table ( :alter_fk_comments ) do
146- modify :alter_fk_user_id , references ( :alter_fk_users , on_delete: :delete_all ) , from: references ( :alter_fk_users , on_delete: :nothing )
152+ modify :alter_fk_user_id , references ( :alter_fk_users , on_delete: :nilify_all ) , from: references ( :alter_fk_users , on_delete: :nothing )
147153 end
148154 end
149155
@@ -566,12 +572,16 @@ defmodule Ecto.Integration.MigrationTest do
566572
567573 assert [ "foo" ] ==
568574 PoolRepo . all from p in "alter_col_migration" , select: p . from_null_to_not_null
575+ assert [ "baz" ] ==
576+ PoolRepo . all from p in "alter_col_migration" , select: p . another_from_null_to_not_null
569577 assert [ nil ] ==
570578 PoolRepo . all from p in "alter_col_migration" , select: p . from_not_null_to_null
571579 assert [ nil ] ==
572580 PoolRepo . all from p in "alter_col_migration" , select: p . from_default_to_no_default
581+ assert [ nil ] ==
582+ PoolRepo . all from p in "alter_col_migration" , select: p . another_from_default_to_no_default
573583 assert [ 0 ] ==
574- PoolRepo . all from p in "alter_col_migration" , select: p . from_no_default_to_default
584+ PoolRepo . all from p in "alter_col_migration" , select: p . another_from_no_default_to_default
575585
576586 query = "INSERT INTO `alter_col_migration` (\" from_not_null_to_null\" ) VALUES ('foo')"
577587 assert catch_error ( PoolRepo . query! ( query ) )
@@ -607,8 +617,10 @@ defmodule Ecto.Integration.MigrationTest do
607617 assert [ id ] = PoolRepo . all from p in "alter_fk_users" , select: p . id
608618
609619 PoolRepo . insert_all ( "alter_fk_posts" , [ [ alter_fk_user_id: id ] ] )
620+ PoolRepo . insert_all ( "alter_fk_comments" , [ [ alter_fk_user_id: id ] ] )
610621 PoolRepo . delete_all ( "alter_fk_users" )
611622 assert [ nil ] == PoolRepo . all from p in "alter_fk_posts" , select: p . alter_fk_user_id
623+ assert [ nil ] == PoolRepo . all from p in "alter_fk_comments" , select: p . alter_fk_user_id
612624
613625 :ok = down ( PoolRepo , num , AlterForeignKeyOnDeleteMigration , log: false )
614626 end
0 commit comments