Skip to content

Commit

Permalink
Merge pull request #29438 from koic/add_migration_compatibility_test
Browse files Browse the repository at this point in the history
Add test for backward compatibility when using change_table
  • Loading branch information
rafaelfranca committed Jun 13, 2017
2 parents db7398f + d923079 commit 326914d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions activerecord/test/cases/migration/compatibility_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ def migrate(x)
connection.drop_table :more_testings rescue nil
end

def test_timestamps_have_null_constraints_if_not_present_in_migration_of_change_table
migration = Class.new(ActiveRecord::Migration[4.2]) {
def migrate(x)
change_table :testings do |t|
t.timestamps
end
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

def test_timestamps_have_null_constraints_if_not_present_in_migration_for_adding_timestamps_to_existing_table
migration = Class.new(ActiveRecord::Migration[4.2]) {
def migrate(x)
Expand Down

0 comments on commit 326914d

Please sign in to comment.