From b23430375ca736c3eacc76aa2e100a668f1b7e0e Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 12 Jun 2014 12:15:37 +1000 Subject: [PATCH] Add migration to remove deleted variants from order cycles --- ...020206_remove_deleted_variants_from_order_cycles.rb | 10 ++++++++++ db/schema.rb | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20140612020206_remove_deleted_variants_from_order_cycles.rb diff --git a/db/migrate/20140612020206_remove_deleted_variants_from_order_cycles.rb b/db/migrate/20140612020206_remove_deleted_variants_from_order_cycles.rb new file mode 100644 index 0000000000..cb03abe09a --- /dev/null +++ b/db/migrate/20140612020206_remove_deleted_variants_from_order_cycles.rb @@ -0,0 +1,10 @@ +class RemoveDeletedVariantsFromOrderCycles < ActiveRecord::Migration + def up + evs = ExchangeVariant.joins(:variant).where('spree_variants.deleted_at IS NOT NULL') + say "Removing #{evs.count} deleted variants from order cycles..." + evs.destroy_all + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 2b3c2cbf62..66205112e0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140604051248) do +ActiveRecord::Schema.define(:version => 20140612020206) do create_table "adjustment_metadata", :force => true do |t| t.integer "adjustment_id" @@ -547,9 +547,9 @@ ActiveRecord::Schema.define(:version => 20140604051248) do t.string "email" t.text "special_instructions" t.integer "distributor_id" + t.integer "order_cycle_id" t.string "currency" t.string "last_ip_address" - t.integer "order_cycle_id" t.integer "cart_id" end