include migration statements on ActiveRecord::Migration #125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, projects with old migration files containing Paperclip schema statements do not perform the same schema changes both before and after an ActiveRecord version upgrade.
Consider the following migration file which will add one datetime column using ActiveRecord's
add_column
and another datetime column as part of Paperclip'sadd_attachment
(note that is is written as an ActiveRecord 6.1 migration).We would expect the two added datetime columns to be identical in everything but name.
When run on Rails 6.1.7.6 it produces the following schema entry as expected:
baz
andfoo_updated_at
both have the same formatWhen run on Rails 7.0.8 it produces the following schema entry:
baz
andfoo_updated_at
have different formats (note thatfoo_updated_at
is no longer added withprecision: nil
as it would have in Rails 6)This is because Paperclip schema statements do not currently respect ActiveRecord::Migration::Compatibility versioning; the logic which ensures that schema statements from old migrations retain consistent behaviour when run within newer versions of ActiveRecord.
This pull request includes Paperclip::Schema::Statements on ActiveRecord::Migration to ensure that Paperclip schema statements are consistent with ActiveRecord::Migration::Compatibility versioning.
When run on Rails 6.1.7.6 it produces the following schema entry as expected:
baz
andfoo_updated_at
both have the same formatWhen run on Rails 7.0.8 it produces the following schema entry as expected:
baz
andfoo_updated_at
both have the same format