aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-01-09 22:29:44 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-01-09 22:29:44 +0900
commitc352f12cbb75636380b06917616e14029f339189 (patch)
tree4a82b79cdba131835c8aff7d423b297c33c80950 /activerecord/test
parentcf865331a3b6c8fa7e6bb541846544f98b6c8bb0 (diff)
downloadrails-c352f12cbb75636380b06917616e14029f339189.tar.gz
rails-c352f12cbb75636380b06917616e14029f339189.tar.bz2
rails-c352f12cbb75636380b06917616e14029f339189.zip
Fix UUID primary key with default nil in legacy migration
UUID primary key with no default value feature (#10404, #18206) was lost in legacy migration caused by #25395 got merged. Restore the feature again in legacy migration.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/adapters/postgresql/uuid_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
index 29052126d2..4655cd1d20 100644
--- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
@@ -283,6 +283,25 @@ class PostgresqlUUIDTestNilDefault < ActiveRecord::PostgreSQLTestCase
schema = dump_table_schema "pg_uuids"
assert_match(/\bcreate_table "pg_uuids", id: :uuid, default: nil/, schema)
end
+
+ def test_schema_dumper_for_uuid_primary_key_with_default_nil_in_legacy_migration
+ @verbose_was = ActiveRecord::Migration.verbose
+ ActiveRecord::Migration.verbose = false
+
+ migration = Class.new(ActiveRecord::Migration[5.0]) do
+ def version; 101 end
+ def migrate(x)
+ create_table("pg_uuids_4", id: :uuid, default: nil)
+ end
+ end.new
+ ActiveRecord::Migrator.new(:up, [migration]).migrate
+
+ schema = dump_table_schema "pg_uuids_4"
+ assert_match(/\bcreate_table "pg_uuids_4", id: :uuid, default: nil/, schema)
+ ensure
+ drop_table "pg_uuids_4"
+ ActiveRecord::Migration.verbose = @verbose_was
+ end
end
end