-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Create data migration for spree_orders.shipment_total #4684
Comments
played a while with sql today, I think something like this might fix the issue is a faster way: UPDATE spree_orders
SET shipment_total = (SELECT SUM(spree_shipments.cost) AS sum_id
FROM spree_shipments
WHERE spree_shipments.order_id = spree_orders.id) I'm just not sure right now if we should add a new migration or update existing ones to add that code. At this point perhaps the ideal fix would be add that sample at some upgrade guide. |
This is also an issue for tax adjustments btw. |
I would not update the existing migration. I think it's better to add a new one. However, because the migration is being added late, don't update shipment_total on records that already have a shipment_total. (Orders that were created in Spree 2.2). Add this to the end: WHERE shipment_total = 0 |
Previous to Spree 2.2 orders didn't have a shipment_total. This should populate that new column for legacy orders Fixes #4684
Added migration to populate that field on 2-2-stable. Still feels weird to have it there but I hope users read the migrations content before they run it in production. thanks @BMorearty |
Previous to Spree 2.2 orders didn't have a shipment_total. This should populate that new column for legacy orders Fixes spree#4684
When the shipment_total column was added to spree_orders, the column was not populated in existing orders (if upgrading from an older version of Spree).
Could someone who's more familiar with the code than I am, please create a migration? Or I'll do it if you point me the right way.
Here's one way that might work:
But it was suggested in IRC that a single SQL "UPDATE" statement might be possible as well, and would certainly be faster.
The text was updated successfully, but these errors were encountered: