diff --git a/CHANGELOG.md b/CHANGELOG.md index 67dd5b39..828c3c7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.7.1 (unreleased) + +- Updated instructions for removing a column to append to `ignored_columns` + ## 1.7.0 (2024-01-05) - Added check for `add_unique_constraint` diff --git a/README.md b/README.md index 8c972767..468d31b8 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Active Record caches attributes, which causes problems when removing columns. Be sure to ignore the column: class User < ApplicationRecord - self.ignored_columns = ["name"] + self.ignored_columns += ["name"] end Deploy the code, then wrap this step in a safety_assured { ... } block. @@ -110,7 +110,7 @@ end ```ruby class User < ApplicationRecord - self.ignored_columns = ["some_column"] + self.ignored_columns += ["some_column"] end ``` diff --git a/lib/strong_migrations/checks.rb b/lib/strong_migrations/checks.rb index 4e686a8e..0a2b34f9 100644 --- a/lib/strong_migrations/checks.rb +++ b/lib/strong_migrations/checks.rb @@ -353,7 +353,7 @@ def check_remove_column(method, *args) cols end - code = "self.ignored_columns = #{columns.inspect}" + code = "self.ignored_columns += #{columns.inspect}" raise_error :remove_column, model: args[0].to_s.classify, diff --git a/test/remove_column_test.rb b/test/remove_column_test.rb index 62c04c7b..1f950d7d 100644 --- a/test/remove_column_test.rb +++ b/test/remove_column_test.rb @@ -10,7 +10,7 @@ def test_remove_columns end def test_remove_columns_type - assert_unsafe RemoveColumnsType, 'self.ignored_columns = ["name", "other"]' + assert_unsafe RemoveColumnsType, 'self.ignored_columns += ["name", "other"]' end def test_remove_timestamps