-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ActiveStorage update migration compatible with install migration #41193
Make ActiveStorage update migration compatible with install migration #41193
Conversation
def change | ||
def up | ||
return if table_exists?(:active_storage_variant_records) | ||
|
||
create_table :active_storage_variant_records do |t| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change to
create_table :active_storage_variant_records do |t| | |
create_table :active_storage_variant_records, if_not_exists: true do |t| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right I had forgotten about this 👍
Also works with as a reversible migration directly.
d727de1
to
11a4ccd
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This is still good to go! |
If you install active_storage in rails 6.1, then use rails app:update, the service name migration handles that case but not the variant records one, which fails trying to re-create the table. Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
11a4ccd
to
51432c6
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
If you install ActiveStorage in rails 6.1, then use
rails app:update
, the service name migration handles that case but not the variant records one, which fails trying to re-create the table.Summary
I updated an app to Rails 6.1, but forgot to run
rails app:update
immediately. Then later I installed ActiveStorage, and finally came back to run the update task.When I saw the update migrations being created in the app, I assumed they would fail but was pleasantly surprised that the service name passed by checking for the presence of the column. So I felt maybe we'd want to do the same to the other migration. We can also assume users will understand and just remove the migrations.
Repro steps:
Other Information
It works perfectly in the regular case: