diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-01-31 23:59:29 -0200 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-01-31 23:59:29 -0200 |
commit | c9daa2690ad64305f04a4fd54d56006a34703198 (patch) | |
tree | d8bae04f3cfc2c94b1b7d7558b821124a5eb25be /activerecord/test/cases/migration/compatibility_test.rb | |
parent | 87e2f7e336b0576f2628cf56dc19655dc1c3eebc (diff) | |
parent | 6e2302ee59e3eebf87f35440cb6b3879ae23c1de (diff) | |
download | rails-c9daa2690ad64305f04a4fd54d56006a34703198.tar.gz rails-c9daa2690ad64305f04a4fd54d56006a34703198.tar.bz2 rails-c9daa2690ad64305f04a4fd54d56006a34703198.zip |
Merge pull request #23374 from prathamesh-sonpatki/migration-compatiblity-tests
Added test for backward compatibility of null constraints on timestamp columns
Diffstat (limited to 'activerecord/test/cases/migration/compatibility_test.rb')
-rw-r--r-- | activerecord/test/cases/migration/compatibility_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb index 6a9cdd9d29..6d5b6243db 100644 --- a/activerecord/test/cases/migration/compatibility_test.rb +++ b/activerecord/test/cases/migration/compatibility_test.rb @@ -71,6 +71,36 @@ module ActiveRecord ensure connection.drop_table :more_testings rescue nil end + + def test_timestamps_have_null_constraints_if_not_present_in_migration_of_create_table + migration = Class.new(ActiveRecord::Migration) { + def migrate(x) + create_table :more_testings do |t| + t.timestamps + end + end + }.new + + ActiveRecord::Migrator.new(:up, [migration]).migrate + + assert connection.columns(:more_testings).find { |c| c.name == 'created_at' }.null + assert connection.columns(:more_testings).find { |c| c.name == 'updated_at' }.null + ensure + connection.drop_table :more_testings rescue nil + end + + def test_timestamps_have_null_constraints_if_not_present_in_migration_for_adding_timestamps_to_existing_table + migration = Class.new(ActiveRecord::Migration) { + def migrate(x) + add_timestamps :testings + end + }.new + + ActiveRecord::Migrator.new(:up, [migration]).migrate + + assert connection.columns(:testings).find { |c| c.name == 'created_at' }.null + assert connection.columns(:testings).find { |c| c.name == 'updated_at' }.null + end end end end |