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
rake app:update
should update active_storage
#33419
rake app:update
should update active_storage
#33419
Conversation
r? @kamipo (@rails-bot has picked a reviewer for you, use r? to override) |
...grate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb
Outdated
Show resolved
Hide resolved
I don’t think we want to copy two migrations into new Rails apps (or existing Rails apps where Active Storage is newly installed). Ideally, we’d copy one migration into new Active Storage installations and add the foreign key migration when an existing installation is upgraded. |
Yep, we have to make it work like @georgeclaghorn suggests. Perhaps we should add a hidden Finally, the upgrade migration should be removed from the codebase in Rails 6.1. |
I've been thinking about that. We could go with this approach, but it looks really complicated to me and I don't see any benefits from doing that since as I understand it only prevents adding one more migration to a newly generated app(but I don't think that it is an issue since it is how a rails engine works).
Currently, I have one concern about that. Example: Also, I'm not sure that it is a good idea to update existing migrations, otherwise we should merge #32042 I guess.
Currently, I lean to the engine's approach with multiple migrations. It would be easier for us to maintain and execution of ActiveStorage's tests would test the migration in this way, see #33419 (comment). Let's discuss about approach we want to go with. |
Since 945e2c4 was backported to |
Let's just catch them on 6.0 and get the upgrading behavior right. |
@bogdanvlviv I still think trying to prevent the extra migration when we don't have to is a win for end users. New users just get the one migration they need, while upgrading users are still taken care of.
Grep the file for the |
@kaspth I think we should consider reverting 945e2c4 and relative changes in |
Agree.. that doesn't look suitable for a patch release to me. |
39434be
to
36ea540
Compare
@@ -12,4 +12,15 @@ namespace :active_storage do | |||
Rake::Task["app:active_storage:install:migrations"].invoke | |||
end | |||
end | |||
|
|||
# desc "Copy over the migrations needed to the application upgrading" | |||
task update: :environment do |
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.
Please let me know what do you think about this approach?
Since we decided to edit the existing migration "create_active_storage_tables" in #33405 in order to generate only one migration for a new app I think we should consider merging this PR - #32042 (but I'm not sure whether it makes sense for now)
/cc @georgeclaghorn, @matthewd
36ea540
to
1e28b88
Compare
Could you please attach the milestone |
Please let me know if there anything I should do? |
1e28b88
to
23b69d8
Compare
de9032a
to
3810759
Compare
…igration We need this in order to be able to add this migration for users that use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0. Related to rails#33405 `rake app:update` should update active_storage `rake app:update` should execute `rake active_storage:update` if it is used in the app that is being updated. It will add new active_storage's migrations to users' apps during update Rails. Context rails#33405 (comment) Also, see a related discussion in the Campfire: https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081
3810759
to
2bad3f4
Compare
Sorry for the delay in reviewing this. This looks good. 👍 Could you please move the update migration to |
Not sure we can do that since blog$ rails active_storage:install
Copied migration 20190116224746_create_active_storage_tables.active_storage.rb from active_storage
Copied migration 20190116224747_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb from active_storage |
Ugh, yes. I tested installing Active Storage in a 5.2 app and upgrading to 6.0 but not installing Active Storage in a 6.0 app. 🤦♂️ |
Thank you for the review! ❤️ |
…igration In rails#33419, we added this migration to properly upgrade Active Storage from 5.2 to 6.0 On Rails 6.1 `rails app:update` shouldn't add this migration to users' app. Note that, I've left implementation that makes `rails app:update` to generate migrations for users' app that are in `activestorage/db/update_migrate/` because we are likely to need it e.g.: rails#34935, rails#36835.
…igration In rails/rails#33419, we added this migration to properly upgrade Active Storage from 5.2 to 6.0 On Rails 6.1 `rails app:update` shouldn't add this migration to users' app. Note that, I've left implementation that makes `rails app:update` to generate migrations for users' app that are in `activestorage/db/update_migrate/` because we are likely to need it e.g.: rails/rails#34935, rails/rails#36835.
Add foreign key to active_storage_attachments for
blob_id
via new migrationWe need this in order to be able to add this migration for users that
use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0.
Related to #33405
rake app:update
should update active_storagerake app:update
should executerake active_storage:update
if it is used in the app that is being updated.
It will add new active_storage's migrations to users' apps during update Rails.
Context #33405 (comment)
Also, see a related discussion in the Campfire:
https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081