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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Refactor create store migration
Rafal Cymerys081f4309bb75
diff --git a/core/db/migrate/20230210142732_create_store_translations.rb b/core/db/migrate/20230210142732_create_store_translations.rbindex 9b5269293b..4fe3cec6ac 100644--- a/core/db/migrate/20230210142732_create_store_translations.rb+++ b/core/db/migrate/20230210142732_create_store_translations.rb@@ -1,19 +1,7 @@class CreateStoreTranslations < ActiveRecord::Migration[6.1]def changeif ActiveRecord::Base.connection.table_exists?('spree_store_translations')- # manually check for index since Rails if_exists does not always work correctly- if ActiveRecord::Migration.connection.index_exists?(:spree_store_translations, :spree_store_id)- remove_index :spree_store_translations, column: :spree_store_id, if_exists: true- end-- add_column :spree_store_translations, :facebook, :string- add_column :spree_store_translations, :twitter, :string- add_column :spree_store_translations, :instagram, :string- add_column :spree_store_translations, :customer_support_email, :string- add_column :spree_store_translations, :description, :text- add_column :spree_store_translations, :address, :text- add_column :spree_store_translations, :contact_phone, :string- add_column :spree_store_translations, :new_order_notifications_email, :string+ add_new_translation_columns_to_globalize_tableelsecreate_table :spree_store_translations do |t|# Translated attribute(s)@@ -41,4 +29,22 @@ class CreateStoreTranslations < ActiveRecord::Migration[6.1]add_index :spree_store_translations, [:spree_store_id, :locale], name: :index_spree_store_translations_on_spree_store_id_locale, unique: trueend++ private++ def add_new_translation_columns_to_globalize_table+ # manually check for index since Rails if_exists does not always work correctly+ if ActiveRecord::Migration.connection.index_exists?(:spree_store_translations, :spree_store_id)+ remove_index :spree_store_translations, column: :spree_store_id, if_exists: true+ end++ add_column :spree_store_translations, :facebook, :string+ add_column :spree_store_translations, :twitter, :string+ add_column :spree_store_translations, :instagram, :string+ add_column :spree_store_translations, :customer_support_email, :string+ add_column :spree_store_translations, :description, :text+ add_column :spree_store_translations, :address, :text+ add_column :spree_store_translations, :contact_phone, :string+ add_column :spree_store_translations, :new_order_notifications_email, :string+ endend