From 2ff0169016f96ddadd59557c87f883450759530d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 13 Sep 2019 12:55:24 +0100 Subject: [PATCH] Replace hard-deleted prices with empty (0.00) price records --- .../20190913023137_replace_hard_deleted_prices.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20190913023137_replace_hard_deleted_prices.rb diff --git a/db/migrate/20190913023137_replace_hard_deleted_prices.rb b/db/migrate/20190913023137_replace_hard_deleted_prices.rb new file mode 100644 index 0000000000..15b34c12a7 --- /dev/null +++ b/db/migrate/20190913023137_replace_hard_deleted_prices.rb @@ -0,0 +1,11 @@ +class ReplaceHardDeletedPrices < ActiveRecord::Migration + def up + ActiveRecord::Base.connection.execute( + "INSERT into spree_prices (variant_id, amount, currency, deleted_at) + SELECT spree_variants.id, '0.00', (SELECT value FROM spree_preferences WHERE key = 'spree/app_configuration/currency'), now() + FROM spree_variants + LEFT OUTER JOIN spree_prices ON (spree_variants.id = spree_prices.variant_id) + WHERE spree_prices.id IS NULL;" + ) + end +end