From 55eea4e42d557037600c71556700bb82fcebcb0a Mon Sep 17 00:00:00 2001 From: fatkodima Date: Mon, 25 Dec 2017 23:41:28 +0200 Subject: Fix `add_column` with :primary_key type compatibility for SQLite --- .../test/cases/migration/compatibility_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'activerecord/test/cases/migration/compatibility_test.rb') diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb index cc2391f349..eb6d65d1b1 100644 --- a/activerecord/test/cases/migration/compatibility_test.rb +++ b/activerecord/test/cases/migration/compatibility_test.rb @@ -267,6 +267,25 @@ module LegacyPrimaryKeyTestCases end end + if current_adapter?(:SQLite3Adapter) + def test_add_column_with_legacy_primary_key_should_work + @migration = Class.new(migration_class) { + def change + create_table :legacy_primary_keys, id: false do |t| + t.integer :dummy + end + add_column :legacy_primary_keys, :id, :primary_key + end + }.new + + @migration.migrate(:up) + + assert_equal "id", LegacyPrimaryKey.primary_key + legacy_pk = LegacyPrimaryKey.columns_hash["id"] + assert_not legacy_pk.null + end + end + def test_legacy_join_table_foreign_keys_should_be_integer @migration = Class.new(migration_class) { def change -- cgit v1.2.3