Ensure db:seed runs before spree_sample:load#4907
Ensure db:seed runs before spree_sample:load#4907lsizani wants to merge 2 commits intosolidusio:mainfrom
Conversation
There was a problem hiding this comment.
Thanks a lot for your collaboration, @lsizani 🙌 🙌 It's a great and long-due improvement 🙂
I left some suggestions. We can probably take the occasion to leverage the new flexibility also in the installer by removing the && @load_seed_data check here:
cecf524 to
858e37f
Compare
kennyadsl
left a comment
There was a problem hiding this comment.
Thanks! I left a comment. Also, I'm curious about what happens if db:seed and sample:load are run independently, one after the other. Is db:seed executed twice in that case?
It will run |
858e37f to
f20a8b1
Compare
|
@lsizani do you know if we have any spec that verify we can run seeds multiple times without breaking or creating duplicate records? |
We do not... But I'm sure I can write one |
bb272d4 to
e191991
Compare
waiting-for-dev
left a comment
There was a problem hiding this comment.
Thanks, it's perfect! ❤️ Last ask, could you please rebase from master so that CI runs? 🙏
397224f to
320235f
Compare
kennyadsl
left a comment
There was a problem hiding this comment.
I just noticed that with this change in the solidus installer, we are executing seeds twice: once during the seeds step and another during the samples step.
I think this is not ideal, no matter if it's safe to run seeds multiple times. Maybe we can merge populate_seed_data and load_sample_data to call a single rake command in case we want both?
6a4fdff to
64a4c0f
Compare
64a4c0f to
a14fcd0
Compare
|
Hey @lsizani! I lost track of this PR, I didn't notice you updated it following my suggestions. I will re-review it now, in the meantime there are some conflict with the |
kennyadsl
left a comment
There was a problem hiding this comment.
Left some questions, thanks again Lunga!
| describe "Load seeds multiple times" do | ||
| it "doesn't duplicate records" do | ||
| 4.times do | ||
| pid = fork { Spree::Core::Engine.load_seed } |
There was a problem hiding this comment.
Will this local variable be overridden at each cycle? Might this interfere with the process killing in the ensure block (it only always kills the last process but previous ones might still be executing)?
| rescue ActiveRecord::RecordNotFound | ||
| puts "Couldn't find 'North America' zone. Did you run `rake db:seed` first?" | ||
| puts "That task will set up the countries, states and zones required for Spree." | ||
| puts <<~TEXT |
| expect { | ||
| Spree::Core::Engine.load_seed | ||
| expect do | ||
| pid = fork { Spree::Core::Engine.load_seed } |
There was a problem hiding this comment.
Why do we need a separate process here instead of just running load_seed and load_sample one after the other?
|
We do not feel comfortable merging this in this state. Please feel free to open it if this issues is still persisting. |
Summary
When running
bundle exec rake spree_sample:loadagainst an empty database, an exception is raised indb/samples/tax_rates.rbon account of missing aSpree::Zonewith the name "North America.In this PR we:
db:seedas a dependent task ofspree_sample:loadSpree::Zone"North America" is present indb/samples/tax_rates.rbbefore running the rest of the seed file. This makes it consistent with db/samples/shipping_methods.rbChecklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed:
I have updated the README to account for my changes.