-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Address name data migration rake task #3933
Add Address name data migration rake task #3933
Conversation
59ac131
to
9bf9e85
Compare
9bf9e85
to
a77b833
Compare
2b7acce
to
519a82d
Compare
I don't get the upgrade strategy proposed. If this code is part of Solidus 3.0, how can we run the task before deploying it? Shouldn't this be part of 2.11? |
@kennyadsl yes it needs to be run in production when the app is still on 2.11, but as a part of the upgrade process to 3.0. Given your question, I guess I did not understand properly these tasks |
You run the task when upgrading from 2.10 to 2.11. This operation immediately makes the host app ready for 2.11, but also for 3.0 that will only contain removal of deprecated code at this point. |
So this means, if I got it correctly, that in 2.11 we'll have both When users switch to Solidus 3, we remove usage of Please let me know if you were thinking of another migration strategy. |
@kennyadsl yes exactly. The code that allows a 2.11 app to work with both Regarding the naming, I guess the problem comes from the fact that it's debatable whether a 3.0 upgrade task should be run before or after the actual upgrade. I would say that there may be cases when a task needs to be run before the upgrade is completed (like this one) and others when the task needs to (or can) be run right after the upgrade. We may use a more descriptive naming in order to clear up some confusion, for example |
Got what you mean, I think that this has almost nothing to do with 3.0 though, which just removes the possibility to choose if combine names or not, forcing This change is just a continuation of the combined name feature and could live in 2.11 even for people that do not plan to upgrade. |
519a82d
to
bc1dd1d
Compare
@kennyadsl I moved the address name migration task into the existing 2.11 upgrade task. |
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.
Great job, left some comments/questions. We are so close!
|
||
RSpec.describe 'solidus:migrations:migrate_address_names' do | ||
around do |example| | ||
self.use_transactional_tests = false |
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.
Can you please explain somewhere why we do need to not use transactional tests and cleanup database tables manually for these specs?
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.
Actually, we don't need this. This is leftover from the early stage of the development when the code also added the index on the column, which is not the case anymore. It can be safely removed 👍
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.
@spaghetticode this looks good, although I'm also curious why we can't use transactional tests here.
2b708bc
to
c7b795d
Compare
Dismissing the approval, I saw that the specs are failing
I saw the failures on the CI and I think it may be due to some ActiveRecord internal caching, which could be probably fixable using reset_column_information. Just a gut feeling, but let me know! |
c7b795d
to
eab21fc
Compare
@kennyadsl thanks for the hint, CI is green now 👍 |
After solidusio#3908 the table spree_addresses includes the name field, so it can be populated with historical data already present in the table by joining the content of firstname and lastname. Running `rails solidus:migrations:migrate_address_names:up` will take care of the job. The task is arranged in steps that require user input in order to proceed: * the task will exit no-op when no record with blank name is found; * if records are found, the user is asked to confirm before proceeding; * the user is now asked for the record batch size to be used. My tests showed that 100'000 records per batch should balance the necessity to avoid locking records for long and have the script complete without too much overhead; * before migrating data, the user is asked to confirm once again. Running this task is required when upgrading to Solidus 3.0.
The Solidus 2.11 upgrade task now includes also the rake task `migrate_address_names`.
eab21fc
to
87203d5
Compare
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.
Thanks, Andrea!
I've been upgraded to solidus 3.0 but name fields are empty. Now I cant access firstname and lastname columns because of they are ignored. How could I update name now? |
@vokshirg did you run the update task on 2.11 before upgrading to 3.0? In this discussion I outlined the suggested path for the upgrade. |
Yes, but that is not possible to remember what was wrong, therefore I've wrote migration and that is helped. Thanks! class FillNamesAtAdresses < ActiveRecord::Migration[6.0]
def up_only
ActiveRecord::Base.connection.execute("UPDATE spree_addresses SET name = CONCAT_WS(' ', firstname, lastname) WHERE name is NULL")
end
end |
Description
After #3908 the table
spree_addresses
includes thename
field, so it can be populated with historical data already present in the table by joining the content offirstname
andlastname
. Runningrake solidus:migrations:migrate_address_names:up
will take care of the job.The task is arranged in steps that require user input in order to proceed:
name
is found;For convenience, the Solidus upgrade task
solidus:upgrade:three_point_zero
has been added that needs to be run when upgrading to Solidus 3.0 (before deploying the 3.0 code) which runs this rake task.Checklist: