From b030793f153b402670fafd307cb8d303c3193cea Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 24 Feb 2013 19:09:43 +1100 Subject: [PATCH] Fix migrations that fail because of coupling to changed/removed models --- db/migrate/20120327000582_polymorphic_payments.rb | 1 + .../20120618061537_move_distributor_from_order_to_product.rb | 3 +++ ...ract_distributor_and_supplier_address_to_spree_address.rb | 5 +++++ ..._rename_distributors_products_to_product_distributions.rb | 5 ++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/db/migrate/20120327000582_polymorphic_payments.rb b/db/migrate/20120327000582_polymorphic_payments.rb index 418c3b30ce..33787c3d26 100644 --- a/db/migrate/20120327000582_polymorphic_payments.rb +++ b/db/migrate/20120327000582_polymorphic_payments.rb @@ -1,5 +1,6 @@ # Legacy table support class Checkout < ActiveRecord::Base; end; +class Spree::Creditcard < ActiveRecord::Base; end; class PolymorphicPayments < ActiveRecord::Migration def up diff --git a/db/migrate/20120618061537_move_distributor_from_order_to_product.rb b/db/migrate/20120618061537_move_distributor_from_order_to_product.rb index ede96641f1..c5f0b18a59 100644 --- a/db/migrate/20120618061537_move_distributor_from_order_to_product.rb +++ b/db/migrate/20120618061537_move_distributor_from_order_to_product.rb @@ -1,4 +1,7 @@ class MoveDistributorFromOrderToProduct < ActiveRecord::Migration + class Distributor < ActiveRecord::Base; end + class Spree::Product < ActiveRecord::Base; end + def up remove_column :spree_orders, :distributor_id diff --git a/db/migrate/20120626013846_extract_distributor_and_supplier_address_to_spree_address.rb b/db/migrate/20120626013846_extract_distributor_and_supplier_address_to_spree_address.rb index fdba0a03ef..89480427ea 100644 --- a/db/migrate/20120626013846_extract_distributor_and_supplier_address_to_spree_address.rb +++ b/db/migrate/20120626013846_extract_distributor_and_supplier_address_to_spree_address.rb @@ -1,4 +1,9 @@ class ExtractDistributorAndSupplierAddressToSpreeAddress < ActiveRecord::Migration + class Supplier < ActiveRecord::Base; end + class Distributor < ActiveRecord::Base; end + class Spree::Address < ActiveRecord::Base; end + + def up # -- Distributors add_column :distributors, :pickup_address_id, :integer diff --git a/db/migrate/20120626233350_rename_distributors_products_to_product_distributions.rb b/db/migrate/20120626233350_rename_distributors_products_to_product_distributions.rb index cca0850150..c2ecd94457 100644 --- a/db/migrate/20120626233350_rename_distributors_products_to_product_distributions.rb +++ b/db/migrate/20120626233350_rename_distributors_products_to_product_distributions.rb @@ -1,4 +1,7 @@ class RenameDistributorsProductsToProductDistributions < ActiveRecord::Migration + class Spree::ShippingMethod < ActiveRecord::Base; end + class ProductDistribution < ActiveRecord::Base; end + def up # Convert m2m join table into explicit join model, and add a shipping method relation and timestamps rename_table :distributors_products, :product_distributions @@ -9,7 +12,7 @@ class RenameDistributorsProductsToProductDistributions < ActiveRecord::Migration end # Set default shipping method on all product distributions - sm = Spree::ShippingMethod.first + sm = Spree::ShippingMethod.unscoped.first ProductDistribution.update_all(:shipping_method_id => sm.id) if sm end