spree_core 4.4.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/finders/spree/option_values/find_available.rb +1 -1
- data/app/finders/spree/product_properties/find_available.rb +1 -1
- data/app/finders/spree/products/find.rb +21 -15
- data/app/finders/spree/taxons/find.rb +11 -8
- data/app/helpers/spree/base_helper.rb +14 -11
- data/app/helpers/spree/locale_helper.rb +6 -2
- data/app/helpers/spree/products_helper.rb +9 -4
- data/app/jobs/spree/variants/remove_from_incomplete_orders_job.rb +9 -0
- data/app/jobs/spree/variants/remove_line_item_job.rb +9 -0
- data/app/models/concerns/spree/calculated_adjustments.rb +1 -1
- data/app/models/concerns/spree/display_link.rb +17 -29
- data/app/models/concerns/spree/image_methods.rb +21 -9
- data/app/models/concerns/spree/metadata.rb +2 -2
- data/app/models/concerns/spree/product_scopes.rb +34 -28
- data/app/models/concerns/spree/translatable_resource.rb +25 -0
- data/app/models/concerns/spree/translatable_resource_scopes.rb +24 -0
- data/app/models/concerns/spree/translatable_resource_slug.rb +17 -0
- data/app/models/spree/address.rb +7 -1
- data/app/models/spree/asset/support/active_storage.rb +3 -2
- data/app/models/spree/asset.rb +3 -0
- data/app/models/spree/base.rb +1 -0
- data/app/models/spree/cms_page.rb +4 -0
- data/app/models/spree/cms_section.rb +12 -12
- data/app/models/spree/cms_section_image.rb +15 -0
- data/app/models/spree/cms_section_image_one.rb +4 -0
- data/app/models/spree/cms_section_image_three.rb +4 -0
- data/app/models/spree/cms_section_image_two.rb +4 -0
- data/app/models/spree/credit_card.rb +10 -4
- data/app/models/spree/customer_return.rb +3 -0
- data/app/models/spree/data_feed/google.rb +15 -0
- data/app/models/spree/data_feed.rb +40 -0
- data/app/models/spree/digital.rb +4 -0
- data/app/models/spree/digital_link.rb +7 -0
- data/app/models/spree/fulfilment_changer.rb +1 -1
- data/app/models/spree/gateway/bogus.rb +1 -1
- data/app/models/spree/icon.rb +5 -1
- data/app/models/spree/image/configuration/active_storage.rb +5 -1
- data/app/models/spree/image.rb +3 -3
- data/app/models/spree/inventory_unit.rb +5 -2
- data/app/models/spree/legacy_user.rb +1 -2
- data/app/models/spree/line_item.rb +4 -1
- data/app/models/spree/linkable/homepage.rb +3 -0
- data/app/models/spree/linkable/uri.rb +3 -0
- data/app/models/spree/log_entry.rb +9 -1
- data/app/models/spree/menu.rb +3 -0
- data/app/models/spree/menu_item.rb +7 -11
- data/app/models/spree/option_type.rb +8 -0
- data/app/models/spree/option_value.rb +9 -0
- data/app/models/spree/order/address_book.rb +1 -0
- data/app/models/spree/order.rb +12 -3
- data/app/models/spree/order_merger.rb +1 -1
- data/app/models/spree/payment/processing.rb +1 -1
- data/app/models/spree/payment.rb +7 -1
- data/app/models/spree/payment_capture_event.rb +4 -0
- data/app/models/spree/payment_method/store_credit.rb +1 -1
- data/app/models/spree/payment_method.rb +3 -0
- data/app/models/spree/payment_source.rb +10 -0
- data/app/models/spree/preference.rb +4 -0
- data/app/models/spree/price.rb +3 -0
- data/app/models/spree/product.rb +97 -24
- data/app/models/spree/product_property.rb +13 -3
- data/app/models/spree/promotion/rules/option_value.rb +2 -2
- data/app/models/spree/promotion.rb +6 -0
- data/app/models/spree/promotion_rule.rb +1 -1
- data/app/models/spree/promotion_rule_user.rb +1 -1
- data/app/models/spree/property.rb +10 -1
- data/app/models/spree/prototype.rb +3 -0
- data/app/models/spree/refund.rb +8 -0
- data/app/models/spree/reimbursement.rb +3 -0
- data/app/models/spree/return_authorization.rb +3 -0
- data/app/models/spree/return_item.rb +4 -0
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/role_user.rb +1 -1
- data/app/models/spree/shipment.rb +8 -1
- data/app/models/spree/shipping_category.rb +3 -0
- data/app/models/spree/shipping_method.rb +6 -0
- data/app/models/spree/state_change.rb +1 -1
- data/app/models/spree/stock/availability_validator.rb +9 -3
- data/app/models/spree/stock/content_item.rb +1 -1
- data/app/models/spree/stock/quantifier.rb +1 -1
- data/app/models/spree/stock_item.rb +5 -0
- data/app/models/spree/stock_location.rb +19 -5
- data/app/models/spree/stock_movement.rb +4 -0
- data/app/models/spree/stock_transfer.rb +3 -0
- data/app/models/spree/store.rb +39 -15
- data/app/models/spree/store_credit.rb +4 -1
- data/app/models/spree/store_favicon_image.rb +17 -0
- data/app/models/spree/store_logo.rb +9 -0
- data/app/models/spree/store_mailer_logo.rb +13 -0
- data/app/models/spree/tax_category.rb +6 -0
- data/app/models/spree/tax_rate.rb +6 -1
- data/app/models/spree/taxon.rb +26 -7
- data/app/models/spree/taxon_image/configuration/active_storage.rb +5 -1
- data/app/models/spree/taxon_image.rb +3 -2
- data/app/models/spree/taxonomy.rb +8 -1
- data/app/models/spree/variant.rb +47 -21
- data/app/models/spree/wished_item.rb +4 -0
- data/app/models/spree/wishlist.rb +4 -1
- data/app/models/spree/zone.rb +3 -0
- data/app/services/spree/addresses/create.rb +1 -1
- data/app/services/spree/addresses/update.rb +7 -2
- data/app/services/spree/cart/remove_line_item.rb +1 -0
- data/app/services/spree/data_feeds/google/optional_attributes.rb +23 -0
- data/app/services/spree/data_feeds/google/optional_sub_attributes.rb +21 -0
- data/app/services/spree/data_feeds/google/products_list.rb +14 -0
- data/app/services/spree/data_feeds/google/required_attributes.rb +67 -0
- data/app/services/spree/data_feeds/google/rss.rb +107 -0
- data/app/services/spree/variants/remove_line_items.rb +15 -0
- data/app/sorters/spree/products/sort.rb +23 -0
- data/brakeman.ignore +326 -18
- data/config/initializers/friendly_id.rb +2 -0
- data/config/initializers/mobility.rb +18 -0
- data/config/locales/en.yml +6 -2
- data/config/routes.rb +43 -0
- data/db/migrate/20211201202851_update_linkable_resource_types.rb +10 -0
- data/db/migrate/20211203082008_add_settings_to_payment_methods.rb +11 -0
- data/db/migrate/20211229162122_disable_propagate_all_variants_by_default.rb +5 -0
- data/db/migrate/20220103082046_add_status_and_make_active_at_to_spree_products.rb +7 -0
- data/db/migrate/20220106230929_add_internal_note_to_spree_orders.rb +5 -0
- data/db/migrate/20220113052823_create_payment_sources.rb +22 -0
- data/db/migrate/20220117100333_add_make_active_at_to_spree_products.rb +17 -0
- data/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb +13 -0
- data/db/migrate/20220201103922_add_first_name_and_last_name_to_spree_users.rb +9 -0
- data/db/migrate/20220222083546_add_barcode_to_spree_variants.rb +6 -0
- data/db/migrate/20220329113557_fix_cms_pages_unique_indexes.rb +8 -0
- data/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb +13 -0
- data/db/migrate/20220706112554_create_product_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220715083542_create_spree_product_translations_for_mobility.rb +7 -0
- data/db/migrate/20220715120222_change_product_name_null_to_true.rb +5 -0
- data/db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220718100948_change_taxon_name_null_to_true.rb +5 -0
- data/db/migrate/20220802070609_add_locale_to_friendly_id_slugs.rb +11 -0
- data/db/migrate/20220802073225_create_spree_product_slug_translations_for_mobility_table_backend.rb +5 -0
- data/db/migrate/20220804073928_transfer_data_to_translatable_tables.rb +66 -0
- data/db/migrate/20221215151408_add_selected_locale_to_spree_users.rb +8 -0
- data/db/migrate/20221219123957_add_deleted_at_to_product_translations.rb +6 -0
- data/db/migrate/20221220133432_add_uniqueness_constraint_to_product_translations.rb +5 -0
- data/db/migrate/20221229132350_create_spree_data_feed_settings.rb +14 -0
- data/db/migrate/20230103144439_create_option_type_translations.rb +26 -0
- data/db/migrate/20230103151034_create_option_value_translations.rb +26 -0
- data/db/migrate/20230109084253_create_product_property_translations.rb +25 -0
- data/db/migrate/20230109094907_transfer_options_data_to_translatable_tables.rb +58 -0
- data/db/migrate/20230109105943_create_property_translations.rb +26 -0
- data/db/migrate/20230109110840_transfer_property_data_to_translatable_tables.rb +59 -0
- data/db/migrate/20230110142344_backfill_friendly_id_slug_locale.rb +15 -0
- data/db/migrate/20230111121534_add_additional_taxon_translation_fields.rb +8 -0
- data/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb +82 -0
- data/db/migrate/20230117115531_create_taxonomy_translations.rb +24 -0
- data/db/migrate/20230117120430_allow_null_taxonomy_name.rb +5 -0
- data/db/migrate/20230117121303_transfer_taxonomy_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210142732_create_store_translations.rb +50 -0
- data/db/migrate/20230210142849_transfer_store_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210230434_add_deleted_at_to_store_translations.rb +6 -0
- data/db/migrate/20230415155958_rename_data_feed_settings_table.rb +5 -0
- data/db/migrate/20230415160828_rename_data_feed_table_columns.rb +7 -0
- data/db/migrate/20230415161226_add_indexes_to_data_feeds_table.rb +5 -0
- data/db/migrate/20230512094803_rename_data_feeds_column_provider_to_type.rb +5 -0
- data/db/migrate/20230514162157_add_index_on_locale_and_permalink_to_spree_taxons.rb +5 -0
- data/lib/friendly_id/paranoia.rb +4 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +13 -2
- data/lib/generators/spree/dummy/templates/package.json +12 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/core/configuration.rb +91 -0
- data/lib/spree/core/controller_helpers/auth.rb +3 -1
- data/lib/spree/core/controller_helpers/currency.rb +7 -5
- data/lib/spree/core/controller_helpers/locale.rb +34 -8
- data/lib/spree/core/controller_helpers/order.rb +4 -2
- data/lib/spree/core/controller_helpers/search.rb +1 -1
- data/lib/spree/core/controller_helpers/store.rb +5 -3
- data/lib/spree/core/dependencies.rb +106 -0
- data/lib/spree/core/dependencies_helper.rb +19 -0
- data/lib/spree/core/engine.rb +53 -38
- data/{app/models/spree → lib/spree/core}/preferences/configuration.rb +3 -0
- data/{app/models/spree → lib/spree/core}/preferences/preferable.rb +3 -0
- data/lib/spree/core/product_duplicator.rb +1 -1
- data/lib/spree/core/product_filters.rb +7 -4
- data/lib/spree/core/search/base.rb +10 -6
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +27 -5
- data/lib/spree/permitted_attributes.rb +9 -7
- data/lib/spree/testing_support/common_rake.rb +1 -0
- data/lib/spree/testing_support/factories/favicon_image_factory.rb +9 -0
- data/lib/spree/testing_support/factories/google_data_feed_factory.rb +8 -0
- data/lib/spree/testing_support/factories/icon_factory.rb +3 -1
- data/lib/spree/testing_support/factories/image_factory.rb +3 -1
- data/lib/spree/testing_support/factories/menu_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +2 -1
- data/lib/spree/testing_support/factories/product_factory.rb +12 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -0
- data/lib/spree/testing_support/factories/product_translation_factory.rb +6 -0
- data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +1 -1
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +3 -2
- data/lib/spree/testing_support/factories/store_factory.rb +2 -1
- data/lib/spree/testing_support/factories/taxon_image_factory.rb +3 -1
- data/lib/spree/testing_support/factories/user_factory.rb +4 -0
- data/lib/spree/testing_support/factories/variant_factory.rb +8 -0
- data/lib/spree/translation_migrations.rb +40 -0
- data/lib/spree_core.rb +2 -1
- data/lib/tasks/core.rake +12 -0
- data/spree_core.gemspec +5 -3
- metadata +152 -52
- data/app/models/friendly_id/slug_decorator.rb +0 -9
- data/app/models/spree/app_configuration.rb +0 -86
- data/lib/friendly_id/slug_rails5_patch.rb +0 -11
- data/lib/spree/core/app_dependencies.rb +0 -126
- /data/{app/models/spree → lib/spree/core}/preferences/preferable_class_methods.rb +0 -0
- /data/{app/models/spree → lib/spree/core}/preferences/scoped_store.rb +0 -0
- /data/{app/models/spree → lib/spree/core}/preferences/store.rb +0 -0
data/config/routes.rb
CHANGED
|
@@ -1 +1,44 @@
|
|
|
1
|
+
# direct method cannot be used inside engine routes
|
|
2
|
+
# see: https://github.com/rails/rails/issues/34872
|
|
3
|
+
Rails.application.routes.draw do
|
|
4
|
+
direct :cdn_image do |model, options|
|
|
5
|
+
if model.blob.service_name == 'cloudinary' && defined?(Cloudinary)
|
|
6
|
+
if model.class.method_defined?(:has_mvariation)
|
|
7
|
+
Cloudinary::Utils.cloudinary_url(model.blob.key,
|
|
8
|
+
width: model.variation.transformations[:resize_to_limit].first,
|
|
9
|
+
height: model.variation.transformations[:resize_to_limit].last,
|
|
10
|
+
crop: :fill
|
|
11
|
+
)
|
|
12
|
+
else
|
|
13
|
+
Cloudinary::Utils.cloudinary_url(model.blob.key)
|
|
14
|
+
end
|
|
15
|
+
elsif model.respond_to?(:signed_id)
|
|
16
|
+
route_for(
|
|
17
|
+
:rails_service_blob_proxy,
|
|
18
|
+
model.signed_id,
|
|
19
|
+
model.filename,
|
|
20
|
+
options.merge(
|
|
21
|
+
host: Spree.cdn_host || Rails.application.routes.default_url_options[:host],
|
|
22
|
+
port: Rails.application.routes.default_url_options[:port]
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
else
|
|
26
|
+
signed_blob_id = model.blob.signed_id
|
|
27
|
+
variation_key = model.variation.key
|
|
28
|
+
filename = model.blob.filename
|
|
29
|
+
|
|
30
|
+
route_for(
|
|
31
|
+
:rails_blob_representation_proxy,
|
|
32
|
+
signed_blob_id,
|
|
33
|
+
variation_key,
|
|
34
|
+
filename,
|
|
35
|
+
options.merge(
|
|
36
|
+
host: Spree.cdn_host || Rails.application.routes.default_url_options[:host],
|
|
37
|
+
port: Rails.application.routes.default_url_options[:port]
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
1
44
|
Spree::Core::Engine.draw_routes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class UpdateLinkableResourceTypes < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
change_column_default :spree_menu_items, :linked_resource_type, 'Spree::Linkable::Uri'
|
|
4
|
+
|
|
5
|
+
Spree::MenuItem.where(linked_resource_type: 'URL').update_all(linked_resource_type: 'Spree::Linkable::Uri')
|
|
6
|
+
Spree::CmsSection.where(linked_resource_type: 'URL').update_all(linked_resource_type: 'Spree::Linkable::Uri')
|
|
7
|
+
Spree::MenuItem.where(linked_resource_type: 'Home Page').update_all(linked_resource_type: 'Spree::Linkable::Homepage')
|
|
8
|
+
Spree::CmsSection.where(linked_resource_type: 'Home Page').update_all(linked_resource_type: 'Spree::Linkable::Homepage')
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class AddSettingsToPaymentMethods < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
change_table :spree_payment_methods do |t|
|
|
4
|
+
if t.respond_to? :jsonb
|
|
5
|
+
add_column :spree_payment_methods, :settings, :jsonb
|
|
6
|
+
else
|
|
7
|
+
add_column :spree_payment_methods, :settings, :json
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class CreatePaymentSources < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
create_table :spree_payment_sources do |t|
|
|
4
|
+
t.string :gateway_payment_profile_id
|
|
5
|
+
t.string :type, index: true
|
|
6
|
+
|
|
7
|
+
t.references :payment_method, index: true, foreign_key: { to_table: :spree_payment_methods }
|
|
8
|
+
t.references :user, index: true, foreign_key: { to_table: :spree_users }
|
|
9
|
+
|
|
10
|
+
if t.respond_to? :jsonb
|
|
11
|
+
t.jsonb :public_metadata
|
|
12
|
+
t.jsonb :private_metadata
|
|
13
|
+
else
|
|
14
|
+
t.json :public_metadata
|
|
15
|
+
t.json :private_metadata
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
t.index [:type, :gateway_payment_profile_id], unique: true, name: 'index_payment_sources_on_type_and_gateway_payment_profile_id'
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class AddMakeActiveAtToSpreeProducts < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
add_column :spree_products, :make_active_at, :datetime
|
|
4
|
+
add_index :spree_products, :make_active_at
|
|
5
|
+
|
|
6
|
+
Spree::Product.
|
|
7
|
+
where('discontinue_on IS NULL or discontinue_on > ?', Time.current).
|
|
8
|
+
where('available_on <= ?', Time.current).
|
|
9
|
+
where(status: 'draft').
|
|
10
|
+
update_all(status: 'active', updated_at: Time.current)
|
|
11
|
+
|
|
12
|
+
Spree::Product.
|
|
13
|
+
where('discontinue_on <= ?', Time.current).
|
|
14
|
+
where.not(status: 'archived').
|
|
15
|
+
update_all(status: 'archived', updated_at: Time.current)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class AddMetadataToSpreeTaxRates < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
change_table :spree_tax_rates do |t|
|
|
4
|
+
if t.respond_to? :jsonb
|
|
5
|
+
add_column :spree_tax_rates, :public_metadata, :jsonb
|
|
6
|
+
add_column :spree_tax_rates, :private_metadata, :jsonb
|
|
7
|
+
else
|
|
8
|
+
add_column :spree_tax_rates, :public_metadata, :json
|
|
9
|
+
add_column :spree_tax_rates, :private_metadata, :json
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
class AddFirstNameAndLastNameToSpreeUsers < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
if Spree.user_class.present?
|
|
4
|
+
users_table_name = Spree.user_class.table_name
|
|
5
|
+
add_column users_table_name, :first_name, :string unless column_exists?(users_table_name, :first_name)
|
|
6
|
+
add_column users_table_name, :last_name, :string unless column_exists?(users_table_name, :last_name)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class FixCmsPagesUniqueIndexes < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
remove_index :spree_cms_pages, [:slug, :store_id, :deleted_at]
|
|
4
|
+
remove_index :spree_cms_pages, [:slug, :store_id], unique: true
|
|
5
|
+
|
|
6
|
+
add_index :spree_cms_pages, [:slug, :store_id, :deleted_at], unique: true
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class AddMetadataToSpreeStockItems < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
change_table :spree_stock_items do |t|
|
|
4
|
+
if t.respond_to? :jsonb
|
|
5
|
+
add_column :spree_stock_items, :public_metadata, :jsonb
|
|
6
|
+
add_column :spree_stock_items, :private_metadata, :jsonb
|
|
7
|
+
else
|
|
8
|
+
add_column :spree_stock_items, :public_metadata, :json
|
|
9
|
+
add_column :spree_stock_items, :private_metadata, :json
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class CreateProductNameAndDescriptionTranslationsForMobilityTableBackend < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
# create translation table only if spree_globalize has not already created it
|
|
4
|
+
if ActiveRecord::Base.connection.table_exists? 'spree_product_translations'
|
|
5
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
6
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_product_translations, :spree_product_id)
|
|
7
|
+
remove_index :spree_product_translations, name: "index_spree_product_translations_on_spree_product_id", if_exists: true
|
|
8
|
+
end
|
|
9
|
+
else
|
|
10
|
+
create_table :spree_product_translations do |t|
|
|
11
|
+
|
|
12
|
+
# Translated attribute(s)
|
|
13
|
+
t.string :name
|
|
14
|
+
t.text :description
|
|
15
|
+
|
|
16
|
+
t.string :locale, null: false
|
|
17
|
+
t.references :spree_product, null: false, foreign_key: true, index: false
|
|
18
|
+
|
|
19
|
+
t.timestamps null: false
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
add_index :spree_product_translations, :locale, name: :index_spree_product_translations_on_locale
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
add_index :spree_product_translations, [:spree_product_id, :locale], name: :unique_product_id_per_locale, unique: true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
class CreateSpreeProductTranslationsForMobility < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
add_column :spree_product_translations, :meta_description, :text, if_not_exists: true
|
|
4
|
+
add_column :spree_product_translations, :meta_keywords, :string, if_not_exists: true
|
|
5
|
+
add_column :spree_product_translations, :meta_title, :string, if_not_exists: true
|
|
6
|
+
end
|
|
7
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class CreateSpreeTaxonNameAndDescriptionTranslationsForMobilityTableBackend < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
# create translation table only if spree_globalize has not already created it
|
|
4
|
+
if ActiveRecord::Base.connection.table_exists? 'spree_taxon_translations'
|
|
5
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
6
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_taxon_translations, :spree_taxon_id)
|
|
7
|
+
# replacing this with index on spree_taxon_id and locale
|
|
8
|
+
remove_index :spree_taxon_translations, name: "index_spree_taxon_translations_on_spree_taxon_id", if_exists: true
|
|
9
|
+
end
|
|
10
|
+
else
|
|
11
|
+
create_table :spree_taxon_translations do |t|
|
|
12
|
+
# Translated attribute(s)
|
|
13
|
+
t.string :name
|
|
14
|
+
t.text :description
|
|
15
|
+
|
|
16
|
+
t.string :locale, null: false
|
|
17
|
+
t.references :spree_taxon, null: false, foreign_key: true, index: false
|
|
18
|
+
|
|
19
|
+
t.timestamps null: false
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
add_index :spree_taxon_translations, :locale, name: :index_spree_taxon_translations_on_locale
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
add_index :spree_taxon_translations, [:spree_taxon_id, :locale], name: :index_spree_taxon_translations_on_spree_taxon_id_and_locale, unique: true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class AddLocaleToFriendlyIdSlugs < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
add_column :friendly_id_slugs, :locale, :string, null: :false, after: :scope
|
|
4
|
+
|
|
5
|
+
remove_index :friendly_id_slugs, [:slug, :sluggable_type]
|
|
6
|
+
add_index :friendly_id_slugs, [:slug, :sluggable_type, :locale], length: { slug: 140, sluggable_type: 50, locale: 2 }
|
|
7
|
+
remove_index :friendly_id_slugs, [:slug, :sluggable_type, :scope]
|
|
8
|
+
add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope, :locale], length: { slug: 70, sluggable_type: 50, scope: 70, locale: 2 }, unique: true, name: :index_friendly_id_slugs_unique
|
|
9
|
+
add_index :friendly_id_slugs, :locale
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
class TransferDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
PRODUCTS_TABLE = 'spree_products'
|
|
4
|
+
PRODUCT_TRANSLATIONS_TABLE = 'spree_product_translations'
|
|
5
|
+
TAXONS_TABLE = 'spree_taxons'
|
|
6
|
+
TAXON_TRANSLATIONS_TABLE = 'spree_taxon_translations'
|
|
7
|
+
|
|
8
|
+
def up
|
|
9
|
+
# Products
|
|
10
|
+
ActiveRecord::Base.connection.execute("
|
|
11
|
+
INSERT INTO #{PRODUCT_TRANSLATIONS_TABLE} (name, description, locale, spree_product_id, created_at, updated_at, meta_description, meta_keywords, meta_title, slug)
|
|
12
|
+
SELECT name, description, '#{DEFAULT_LOCALE}' as locale, id, created_at, updated_at, meta_description, meta_keywords, meta_title, slug FROM #{PRODUCTS_TABLE}
|
|
13
|
+
")
|
|
14
|
+
ActiveRecord::Base.connection.execute("
|
|
15
|
+
UPDATE #{PRODUCTS_TABLE}
|
|
16
|
+
SET name=null, description=null, meta_description=null, meta_keywords=null, meta_title=null, slug=null;
|
|
17
|
+
")
|
|
18
|
+
#Taxons
|
|
19
|
+
ActiveRecord::Base.connection.execute("
|
|
20
|
+
INSERT INTO #{TAXON_TRANSLATIONS_TABLE} (name, description, locale, spree_taxon_id, created_at, updated_at)
|
|
21
|
+
SELECT name, description, '#{DEFAULT_LOCALE}' as locale, id, created_at, updated_at FROM #{TAXONS_TABLE}
|
|
22
|
+
")
|
|
23
|
+
ActiveRecord::Base.connection.execute("
|
|
24
|
+
UPDATE #{TAXONS_TABLE}
|
|
25
|
+
SET name=null, description=null
|
|
26
|
+
")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def down
|
|
30
|
+
ActiveRecord::Base.connection.execute("
|
|
31
|
+
UPDATE #{PRODUCTS_TABLE} as products
|
|
32
|
+
SET (name,
|
|
33
|
+
description,
|
|
34
|
+
meta_description,
|
|
35
|
+
meta_keywords,
|
|
36
|
+
meta_title,
|
|
37
|
+
slug) =
|
|
38
|
+
(t_products.name,
|
|
39
|
+
t_products.description,
|
|
40
|
+
t_products.meta_description,
|
|
41
|
+
t_products.meta_keywords,
|
|
42
|
+
t_products.meta_title,
|
|
43
|
+
t_products.slug)
|
|
44
|
+
FROM #{PRODUCT_TRANSLATIONS_TABLE} AS t_products
|
|
45
|
+
WHERE t_products.spree_product_id = products.id
|
|
46
|
+
")
|
|
47
|
+
|
|
48
|
+
ActiveRecord::Base.connection.execute("
|
|
49
|
+
TRUNCATE TABLE #{PRODUCT_TRANSLATIONS_TABLE}
|
|
50
|
+
")
|
|
51
|
+
|
|
52
|
+
ActiveRecord::Base.connection.execute("
|
|
53
|
+
UPDATE #{TAXONS_TABLE} as taxons
|
|
54
|
+
SET (name,
|
|
55
|
+
description) =
|
|
56
|
+
(t_taxons.name,
|
|
57
|
+
t_taxons.description)
|
|
58
|
+
FROM #{TAXON_TRANSLATIONS_TABLE} AS t_taxons
|
|
59
|
+
WHERE t_taxons.spree_taxon_id = taxons.id
|
|
60
|
+
")
|
|
61
|
+
|
|
62
|
+
ActiveRecord::Base.connection.execute("
|
|
63
|
+
TRUNCATE TABLE #{TAXON_TRANSLATIONS_TABLE}
|
|
64
|
+
")
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class AddSelectedLocaleToSpreeUsers < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if Spree.user_class.present?
|
|
4
|
+
users_table_name = Spree.user_class.table_name
|
|
5
|
+
add_column users_table_name, :selected_locale, :string unless column_exists?(users_table_name, :selected_locale)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateSpreeDataFeedSettings < ActiveRecord::Migration[6.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :spree_data_feed_settings do |t|
|
|
4
|
+
t.references :spree_store
|
|
5
|
+
|
|
6
|
+
t.string :name
|
|
7
|
+
t.string :provider
|
|
8
|
+
t.string :uuid, unique: true
|
|
9
|
+
t.boolean :enabled, default: true
|
|
10
|
+
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class CreateOptionTypeTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists? 'spree_option_type_translations'
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_option_type_translations, :spree_option_type_id)
|
|
6
|
+
remove_index :spree_option_type_translations, name: "index_spree_option_type_translations_on_spree_option_type_id", if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_option_type_translations do |t|
|
|
10
|
+
|
|
11
|
+
# Translated attribute(s)
|
|
12
|
+
t.string :name
|
|
13
|
+
t.string :presentation
|
|
14
|
+
|
|
15
|
+
t.string :locale, null: false
|
|
16
|
+
t.references :spree_option_type, null: false, foreign_key: true, index: false
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
add_index :spree_option_type_translations, :locale, name: :index_spree_option_type_translations_on_locale
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
add_index :spree_option_type_translations, [:spree_option_type_id, :locale], name: :unique_option_type_id_per_locale, unique: true
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class CreateOptionValueTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists? 'spree_option_value_translations'
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_option_value_translations, :spree_option_value_id)
|
|
6
|
+
remove_index :spree_option_value_translations, column: :spree_option_value_id, if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_option_value_translations do |t|
|
|
10
|
+
|
|
11
|
+
# Translated attribute(s)
|
|
12
|
+
t.string :name
|
|
13
|
+
t.string :presentation
|
|
14
|
+
|
|
15
|
+
t.string :locale, null: false
|
|
16
|
+
t.references :spree_option_value, null: false, foreign_key: true, index: false
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
add_index :spree_option_value_translations, :locale, name: :index_spree_option_value_translations_on_locale
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
add_index :spree_option_value_translations, [:spree_option_value_id, :locale], name: :unique_option_value_id_per_locale, unique: true
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class CreateProductPropertyTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists? 'spree_product_property_translations'
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_product_property_translations, :spree_product_property_id)
|
|
6
|
+
remove_index :spree_product_property_translations, column: :spree_product_property_id, if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_product_property_translations do |t|
|
|
10
|
+
# Translated attribute(s)
|
|
11
|
+
t.string :value
|
|
12
|
+
t.string :filter_param
|
|
13
|
+
|
|
14
|
+
t.string :locale, null: false
|
|
15
|
+
t.references :spree_product_property, null: false, foreign_key: true, index: false
|
|
16
|
+
|
|
17
|
+
t.timestamps
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
add_index :spree_product_property_translations, :locale, name: :index_spree_product_property_translations_on_locale
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
add_index :spree_product_property_translations, [:spree_product_property_id, :locale], name: :unique_product_property_id_per_locale, unique: true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
class TransferOptionsDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
# Only transfer data if translation tables are being newly created / no translations exist
|
|
6
|
+
# Otherwise, assume translation data is already in place from spree_globalize
|
|
7
|
+
|
|
8
|
+
# Option Types
|
|
9
|
+
if not Spree::OptionType::Translation.exists?
|
|
10
|
+
ActiveRecord::Base.connection.execute("
|
|
11
|
+
INSERT INTO spree_option_type_translations (name, presentation, locale, spree_option_type_id, created_at, updated_at)
|
|
12
|
+
SELECT name, presentation, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
13
|
+
FROM spree_option_types;
|
|
14
|
+
")
|
|
15
|
+
ActiveRecord::Base.connection.execute("
|
|
16
|
+
UPDATE spree_option_types
|
|
17
|
+
SET name=null, presentation=null;
|
|
18
|
+
")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Option Values
|
|
22
|
+
if not Spree::OptionValue::Translation.exists?
|
|
23
|
+
ActiveRecord::Base.connection.execute("
|
|
24
|
+
INSERT INTO spree_option_value_translations (name, presentation, locale, spree_option_value_id, created_at, updated_at)
|
|
25
|
+
SELECT name, presentation, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
26
|
+
FROM spree_option_values;
|
|
27
|
+
")
|
|
28
|
+
ActiveRecord::Base.connection.execute("
|
|
29
|
+
UPDATE spree_option_values
|
|
30
|
+
SET name=null, presentation=null;
|
|
31
|
+
")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def down
|
|
36
|
+
# Option Types
|
|
37
|
+
ActiveRecord::Base.connection.execute("
|
|
38
|
+
UPDATE spree_option_types as option_types
|
|
39
|
+
SET (name, presentation) = (t_option_types.name, t_option_types.presentation)
|
|
40
|
+
FROM spree_option_type_translations AS t_option_types
|
|
41
|
+
WHERE t_option_types.spree_option_type_id = option_types.id;
|
|
42
|
+
")
|
|
43
|
+
ActiveRecord::Base.connection.execute("
|
|
44
|
+
TRUNCATE TABLE spree_option_type_translations;
|
|
45
|
+
")
|
|
46
|
+
|
|
47
|
+
# Option Values
|
|
48
|
+
ActiveRecord::Base.connection.execute("
|
|
49
|
+
UPDATE spree_option_values as option_values
|
|
50
|
+
SET (name, presentation) = (t_option_values.name, t_option_values.presentation)
|
|
51
|
+
FROM spree_option_value_translations AS t_option_values
|
|
52
|
+
WHERE t_option_values.spree_option_value_id = option_values.id;
|
|
53
|
+
")
|
|
54
|
+
ActiveRecord::Base.connection.execute("
|
|
55
|
+
TRUNCATE TABLE spree_option_value_translations;
|
|
56
|
+
")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class CreatePropertyTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists?('spree_property_translations')
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_property_translations, :spree_property_id)
|
|
6
|
+
remove_index :spree_property_translations, column: :spree_property_id, if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_property_translations do |t|
|
|
10
|
+
# Translated attribute(s)
|
|
11
|
+
t.string :name
|
|
12
|
+
t.string :presentation
|
|
13
|
+
t.string :filter_param
|
|
14
|
+
|
|
15
|
+
t.string :locale, null: false
|
|
16
|
+
t.references :spree_property, null: false, foreign_key: true, index: false
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
add_index :spree_property_translations, :locale, name: :index_spree_property_translations_on_locale
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
add_index :spree_property_translations, [:spree_property_id, :locale], name: :unique_property_id_per_locale, unique: true
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
class TransferPropertyDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
# Properties
|
|
6
|
+
change_column_null :spree_properties, :presentation, true
|
|
7
|
+
|
|
8
|
+
if not Spree::Property::Translation.exists?
|
|
9
|
+
ActiveRecord::Base.connection.execute("
|
|
10
|
+
INSERT INTO spree_property_translations (name, presentation, filter_param, locale, spree_property_id, created_at, updated_at)
|
|
11
|
+
SELECT name, presentation, filter_param, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
12
|
+
FROM spree_properties;
|
|
13
|
+
")
|
|
14
|
+
ActiveRecord::Base.connection.execute("
|
|
15
|
+
UPDATE spree_properties
|
|
16
|
+
SET name=null, presentation=null, filter_param=null;
|
|
17
|
+
")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Product Properties
|
|
21
|
+
if not Spree::ProductProperty::Translation.exists?
|
|
22
|
+
ActiveRecord::Base.connection.execute("
|
|
23
|
+
INSERT INTO spree_product_property_translations (value, filter_param, locale, spree_product_property_id, created_at, updated_at)
|
|
24
|
+
SELECT value, filter_param, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
25
|
+
FROM spree_product_properties;
|
|
26
|
+
")
|
|
27
|
+
ActiveRecord::Base.connection.execute("
|
|
28
|
+
UPDATE spree_product_properties
|
|
29
|
+
SET value=null, filter_param=null;
|
|
30
|
+
")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def down
|
|
35
|
+
# Properties
|
|
36
|
+
change_column_null :spree_properties, :presentation, false
|
|
37
|
+
|
|
38
|
+
ActiveRecord::Base.connection.execute("
|
|
39
|
+
UPDATE spree_properties AS properties
|
|
40
|
+
SET (name, presentation, filter_param) = (t_properties.name, t_properties.presentation, t_properties.filter_param)
|
|
41
|
+
FROM spree_property_translations AS t_properties
|
|
42
|
+
WHERE t_properties.spree_property_id = properties.id;
|
|
43
|
+
")
|
|
44
|
+
ActiveRecord::Base.connection.execute("
|
|
45
|
+
TRUNCATE TABLE spree_property_translations;
|
|
46
|
+
")
|
|
47
|
+
|
|
48
|
+
# Product Properties
|
|
49
|
+
ActiveRecord::Base.connection.execute("
|
|
50
|
+
UPDATE spree_product_properties AS product_properties
|
|
51
|
+
SET (value, filter_param) = (t_product_properties.value, t_product_properties.filter_param)
|
|
52
|
+
FROM spree_product_property_translations AS t_product_properties
|
|
53
|
+
WHERE t_product_properties.spree_product_property_id = product_properties.id;
|
|
54
|
+
")
|
|
55
|
+
ActiveRecord::Base.connection.execute("
|
|
56
|
+
TRUNCATE TABLE spree_product_property_translations;
|
|
57
|
+
")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class BackfillFriendlyIdSlugLocale < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
ActiveRecord::Base.connection.execute("
|
|
6
|
+
UPDATE friendly_id_slugs SET locale = '#{DEFAULT_LOCALE}'
|
|
7
|
+
")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def down
|
|
11
|
+
ActiveRecord::Base.connection.execute("
|
|
12
|
+
UPDATE friendly_id_slugs SET locale = NULL
|
|
13
|
+
")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class AddAdditionalTaxonTranslationFields < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
add_column :spree_taxon_translations, :meta_title, :string, if_not_exists: true
|
|
4
|
+
add_column :spree_taxon_translations, :meta_description, :string, if_not_exists: true
|
|
5
|
+
add_column :spree_taxon_translations, :meta_keywords, :string, if_not_exists: true
|
|
6
|
+
add_column :spree_taxon_translations, :permalink, :string, if_not_exists: true
|
|
7
|
+
end
|
|
8
|
+
end
|