Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

* refactor new migration * update sandbox installer

Łukasz Adamczyka8542efbe3bf
diff --git a/bin/sandbox.sh b/bin/sandbox.sh
index a4f6915fbb..cd4d6081cc 100755
--- a/bin/sandbox.sh
+++ b/bin/sandbox.sh
@@ -79,7 +79,6 @@ $SPREE_GATEWAY_GEM
gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: 'master'
gem 'spree_static_content', github: 'spree-contrib/spree_static_content', branch: 'master'
gem 'spree_related_products', github: 'spree-contrib/spree_related_products', branch: 'master'
-gem 'spree_multi_domain', github: 'spree-contrib/spree-multi-domain', branch: 'master'
group :test, :development do
gem 'bullet'
@@ -114,5 +113,4 @@ bundle exec rails g spree_gateway:install
if [ "$SPREE_HEADLESS" == "" ]; then
bundle exec rails g spree_related_products:install
bundle exec rails g spree_static_content:install
- bundle exec rails g spree_multi_domain:install
fi
diff --git a/core/db/migrate/20210527094055_create_spree_products_stores.rb b/core/db/migrate/20210527094055_create_spree_products_stores.rb
index d1d98468b6..e9557711b1 100644
--- a/core/db/migrate/20210527094055_create_spree_products_stores.rb
+++ b/core/db/migrate/20210527094055_create_spree_products_stores.rb
@@ -1,12 +1,12 @@
class CreateSpreeProductsStores < ActiveRecord::Migration[5.2]
- def change
- create_table :spree_products_stores, id: :serial do |t|
+ def up
+ create_table :spree_products_stores, id: :serial, if_not_exists: true do |t|
t.references :product, index: true
t.references :store, index: true
t.timestamps
- end
- add_index :spree_products_stores, [:product_id, :store_id], unique: true
+ t.index [:product_id, :store_id], unique: true
+ end
stores = Spree::Store.all
product_ids = Spree::Product.with_deleted.order(:id).ids
@@ -15,7 +15,13 @@ class CreateSpreeProductsStores < ActiveRecord::Migration[5.2]
prepared_values = product_ids.map { |id| "(#{id}, #{store.id}, '#{Time.current.to_s(:db)}', '#{Time.current.to_s(:db)}')" }.join(', ')
next if prepared_values.empty?
- execute "INSERT INTO spree_products_stores (product_id, store_id, created_at, updated_at) VALUES #{prepared_values};"
+ begin
+ execute "INSERT INTO spree_products_stores (product_id, store_id, created_at, updated_at) VALUES #{prepared_values};"
+ rescue ActiveRecord::RecordNotUnique; end
end
end
+
+ def down
+ drop_table :spree_products_stores
+ end
end