mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix migrations that fail because of coupling to changed/removed models
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# Legacy table support
|
||||
class Checkout < ActiveRecord::Base; end;
|
||||
class Spree::Creditcard < ActiveRecord::Base; end;
|
||||
|
||||
class PolymorphicPayments < ActiveRecord::Migration
|
||||
def up
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user