solidus_promotions 4.4.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 +7 -0
- data/.eslintrc.json +10 -0
- data/.github/stale.yml +1 -0
- data/MIGRATING.md +184 -0
- data/README.md +122 -0
- data/Rakefile +20 -0
- data/app/assets/config/solidus_promotions/manifest.js +13 -0
- data/app/decorators/models/solidus_promotions/adjustment_decorator.rb +11 -0
- data/app/decorators/models/solidus_promotions/line_item_decorator.rb +27 -0
- data/app/decorators/models/solidus_promotions/order_decorator.rb +42 -0
- data/app/decorators/models/solidus_promotions/order_recalculator_decorator.rb +15 -0
- data/app/decorators/models/solidus_promotions/shipment_decorator.rb +14 -0
- data/app/decorators/models/solidus_promotions/shipping_rate_decorator.rb +29 -0
- data/app/helpers/solidus_promotions/admin/benefits_helper.rb +19 -0
- data/app/helpers/solidus_promotions/admin/conditions_helper.rb +14 -0
- data/app/helpers/solidus_promotions/admin/promotions_helper.rb +15 -0
- data/app/javascript/backend/solidus_promotions/controllers/application.js +9 -0
- data/app/javascript/backend/solidus_promotions/controllers/calculator_tiers_controller.js +37 -0
- data/app/javascript/backend/solidus_promotions/controllers/flash_controller.js +10 -0
- data/app/javascript/backend/solidus_promotions/controllers/index.js +8 -0
- data/app/javascript/backend/solidus_promotions/controllers/product_option_values_controller.js +62 -0
- data/app/javascript/backend/solidus_promotions/web_components/number_with_currency.js +35 -0
- data/app/javascript/backend/solidus_promotions/web_components/option_value_picker.js +52 -0
- data/app/javascript/backend/solidus_promotions/web_components/product_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions/web_components/select_two.js +11 -0
- data/app/javascript/backend/solidus_promotions/web_components/taxon_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions/web_components/user_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions/web_components/variant_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions.js +11 -0
- data/app/jobs/solidus_promotions/promotion_code_batch_job.rb +26 -0
- data/app/mailers/solidus_promotions/promotion_code_batch_mailer.rb +15 -0
- data/app/models/concerns/solidus_promotions/benefits/line_item_benefit.rb +15 -0
- data/app/models/concerns/solidus_promotions/benefits/order_benefit.rb +15 -0
- data/app/models/concerns/solidus_promotions/benefits/shipment_benefit.rb +15 -0
- data/app/models/concerns/solidus_promotions/calculators/promotion_calculator.rb +11 -0
- data/app/models/concerns/solidus_promotions/conditions/line_item_applicable_order_level_condition.rb +23 -0
- data/app/models/concerns/solidus_promotions/conditions/line_item_level_condition.rb +15 -0
- data/app/models/concerns/solidus_promotions/conditions/order_level_condition.rb +15 -0
- data/app/models/concerns/solidus_promotions/conditions/shipment_level_condition.rb +15 -0
- data/app/models/concerns/solidus_promotions/discountable_amount.rb +21 -0
- data/app/models/solidus_promotions/benefit.rb +123 -0
- data/app/models/solidus_promotions/benefits/adjust_line_item.rb +13 -0
- data/app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb +107 -0
- data/app/models/solidus_promotions/benefits/adjust_shipment.rb +13 -0
- data/app/models/solidus_promotions/benefits/create_discounted_item.rb +49 -0
- data/app/models/solidus_promotions/calculators/distributed_amount.rb +31 -0
- data/app/models/solidus_promotions/calculators/flat_rate.rb +23 -0
- data/app/models/solidus_promotions/calculators/flexi_rate.rb +26 -0
- data/app/models/solidus_promotions/calculators/percent.rb +19 -0
- data/app/models/solidus_promotions/calculators/tiered_flat_rate.rb +58 -0
- data/app/models/solidus_promotions/calculators/tiered_percent.rb +68 -0
- data/app/models/solidus_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb +40 -0
- data/app/models/solidus_promotions/condition.rb +61 -0
- data/app/models/solidus_promotions/condition_product.rb +8 -0
- data/app/models/solidus_promotions/condition_store.rb +8 -0
- data/app/models/solidus_promotions/condition_taxon.rb +8 -0
- data/app/models/solidus_promotions/condition_user.rb +8 -0
- data/app/models/solidus_promotions/conditions/discounted_item_total.rb +22 -0
- data/app/models/solidus_promotions/conditions/first_order.rb +31 -0
- data/app/models/solidus_promotions/conditions/first_repeat_purchase_since.rb +31 -0
- data/app/models/solidus_promotions/conditions/item_total.rb +75 -0
- data/app/models/solidus_promotions/conditions/line_item_option_value.rb +37 -0
- data/app/models/solidus_promotions/conditions/line_item_product.rb +56 -0
- data/app/models/solidus_promotions/conditions/line_item_taxon.rb +59 -0
- data/app/models/solidus_promotions/conditions/minimum_quantity.rb +42 -0
- data/app/models/solidus_promotions/conditions/nth_order.rb +40 -0
- data/app/models/solidus_promotions/conditions/one_use_per_user.rb +25 -0
- data/app/models/solidus_promotions/conditions/option_value.rb +28 -0
- data/app/models/solidus_promotions/conditions/product.rb +85 -0
- data/app/models/solidus_promotions/conditions/shipping_method.rb +19 -0
- data/app/models/solidus_promotions/conditions/store.rb +26 -0
- data/app/models/solidus_promotions/conditions/taxon.rb +98 -0
- data/app/models/solidus_promotions/conditions/user.rb +35 -0
- data/app/models/solidus_promotions/conditions/user_logged_in.rb +16 -0
- data/app/models/solidus_promotions/conditions/user_role.rb +42 -0
- data/app/models/solidus_promotions/distributed_amounts_handler.rb +39 -0
- data/app/models/solidus_promotions/eligibility_result.rb +5 -0
- data/app/models/solidus_promotions/eligibility_results.rb +47 -0
- data/app/models/solidus_promotions/item_discount.rb +21 -0
- data/app/models/solidus_promotions/migration_support/order_promotion_syncer.rb +54 -0
- data/app/models/solidus_promotions/order_adjuster/choose_discounts.rb +21 -0
- data/app/models/solidus_promotions/order_adjuster/discount_order.rb +93 -0
- data/app/models/solidus_promotions/order_adjuster/load_promotions.rb +53 -0
- data/app/models/solidus_promotions/order_adjuster/persist_discounted_order.rb +79 -0
- data/app/models/solidus_promotions/order_adjuster.rb +33 -0
- data/app/models/solidus_promotions/order_promotion.rb +23 -0
- data/app/models/solidus_promotions/permission_sets/solidus_promotion_management.rb +15 -0
- data/app/models/solidus_promotions/promotion.rb +163 -0
- data/app/models/solidus_promotions/promotion_advertiser.rb +10 -0
- data/app/models/solidus_promotions/promotion_category.rb +9 -0
- data/app/models/solidus_promotions/promotion_code/batch_builder.rb +73 -0
- data/app/models/solidus_promotions/promotion_code.rb +56 -0
- data/app/models/solidus_promotions/promotion_code_batch.rb +25 -0
- data/app/models/solidus_promotions/promotion_finder.rb +10 -0
- data/app/models/solidus_promotions/promotion_handler/coupon.rb +113 -0
- data/app/models/solidus_promotions/promotion_handler/page.rb +30 -0
- data/app/models/solidus_promotions/shipping_rate_discount.rb +11 -0
- data/app/subscribers/solidus_promotions/order_promotion_subscriber.rb +20 -0
- data/bin/rails +13 -0
- data/config/importmap.rb +14 -0
- data/config/locales/en.yml +376 -0
- data/config/locales/promotion_categories.en.yml +6 -0
- data/config/locales/promotions.en.yml +6 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20230703101637_create_promotions.rb +25 -0
- data/db/migrate/20230703113625_create_promotion_benefits.rb +15 -0
- data/db/migrate/20230703141116_create_promotion_categories.rb +14 -0
- data/db/migrate/20230703143943_create_promotion_conditions.rb +12 -0
- data/db/migrate/20230704083830_add_condition_join_tables.rb +31 -0
- data/db/migrate/20230704102444_create_promotion_codes.rb +11 -0
- data/db/migrate/20230704102656_create_promotion_code_batches.rb +34 -0
- data/db/migrate/20230705171556_create_order_promotions.rb +11 -0
- data/db/migrate/20230725074235_create_shipping_rate_discounts.rb +12 -0
- data/db/migrate/20231011100059_add_db_comments_to_order_promotions.rb +61 -0
- data/db/migrate/20231011120928_add_db_comments_to_condition_taxons.rb +54 -0
- data/db/migrate/20231011131324_add_db_comments_to_conditions.rb +60 -0
- data/db/migrate/20231011142040_add_db_comments_to_condition_users.rb +53 -0
- data/db/migrate/20231011155822_add_db_comments_to_promotions.rb +123 -0
- data/db/migrate/20231011163030_add_db_comments_to_promotion_codes.rb +60 -0
- data/db/migrate/20231011173312_add_db_comments_to_promotion_code_batches.rb +91 -0
- data/db/migrate/20231011184205_add_db_comments_to_condition_stores.rb +53 -0
- data/db/migrate/20231011190222_add_db_comments_to_benefits.rb +61 -0
- data/db/migrate/20231012020928_add_db_comments_to_condition_products.rb +52 -0
- data/db/migrate/20231012120928_add_db_comments_to_promotion_categories.rb +52 -0
- data/db/migrate/20231104135812_add_managed_by_order_benefit_to_line_items.rb +5 -0
- data/lib/components/admin/solidus_admin/orders/show/adjustments/index/source/solidus_promotions_benefit/component.rb +17 -0
- data/lib/components/admin/solidus_promotions/orders/index/component.rb +15 -0
- data/lib/components/admin/solidus_promotions/orders/index/component.yml +3 -0
- data/lib/components/admin/solidus_promotions/promotion_categories/index/component.rb +60 -0
- data/lib/components/admin/solidus_promotions/promotions/index/component.rb +108 -0
- data/lib/components/admin/solidus_promotions/promotions/index/component.yml +10 -0
- data/lib/controllers/admin/solidus_promotions/promotion_categories_controller.rb +29 -0
- data/lib/controllers/admin/solidus_promotions/promotions_controller.rb +46 -0
- data/lib/controllers/backend/solidus_promotions/admin/base_controller.rb +15 -0
- data/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb +85 -0
- data/lib/controllers/backend/solidus_promotions/admin/conditions_controller.rb +69 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotion_categories_controller.rb +13 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotion_code_batches_controller.rb +42 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb +58 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotions_controller.rb +65 -0
- data/lib/generators/solidus_promotions/install/install_generator.rb +56 -0
- data/lib/generators/solidus_promotions/install/templates/initializer.rb +6 -0
- data/lib/solidus_promotions/configuration.rb +125 -0
- data/lib/solidus_promotions/engine.rb +115 -0
- data/lib/solidus_promotions/migrate_adjustments.rb +62 -0
- data/lib/solidus_promotions/migrate_order_promotions.rb +73 -0
- data/lib/solidus_promotions/promotion_map.rb +126 -0
- data/lib/solidus_promotions/promotion_migrator.rb +103 -0
- data/lib/solidus_promotions/testing_support/factories/completed_order_with_solidus_promotion_factory.rb +20 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_order_promotion_factory.rb +8 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_promotion_category_factory.rb +7 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_promotion_code_factory.rb +8 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_promotion_factory.rb +65 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_shipping_rate_discount_factory.rb +14 -0
- data/lib/solidus_promotions/testing_support/factory_bot.rb +30 -0
- data/lib/solidus_promotions.rb +37 -0
- data/lib/tasks/solidus_promotions/migrate_adjustments.rake +17 -0
- data/lib/tasks/solidus_promotions/migrate_existing_promotions.rake +12 -0
- data/lib/tasks/solidus_promotions/migrate_order_promotions.rake +17 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_line_item.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_line_item_quantity_groups.html.erb +13 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_shipment.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_calculator_fields.erb +11 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_create_discounted_item.html.erb +21 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_benefit.html.erb +50 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_calculator_select.html.erb +16 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_form.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_new_benefit.html.erb +33 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_type_select.html.erb +16 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/edit.html.erb +19 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/new.html.erb +1 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/_default_fields.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/distributed_amount/_fields.html.erb +18 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/flat_rate/_fields.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb +24 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/percent/_fields.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb +32 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_flat_rate/_tier_fields.html.erb +31 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb +47 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent/_tier_fields.html.erb +33 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_fields.html.erb +36 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +35 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_first_order.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb +7 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_item_total.html.erb +15 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_option_value.html.erb +25 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_product.html.erb +21 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_taxon.html.erb +17 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_minimum_quantity.html.erb +5 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_nth_order.html.erb +15 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_one_use_per_user.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_option_value.html.erb +63 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_product.html.erb +27 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_shipping_method.html.erb +10 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_store.html.erb +9 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_taxon.html.erb +27 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_user.html.erb +7 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_user_logged_in.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_user_role.html.erb +15 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb +21 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/_condition.html.erb +26 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/_new_condition.html.erb +26 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/_type_select.html.erb +20 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/new.html.erb +1 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/_form.html.erb +14 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/edit.html.erb +10 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/index.html.erb +47 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/new.html.erb +10 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/_form_fields.html.erb +22 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/download.csv.ruby +8 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/index.html.erb +65 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/new.html.erb +8 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_codes/index.csv.ruby +8 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_codes/index.html.erb +32 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_codes/new.html.erb +31 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/_form.html.erb +124 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/_table.html.erb +57 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/_table_filter.html.erb +78 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/edit.html.erb +41 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/index.html.erb +23 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/new.html.erb +9 -0
- data/lib/views/backend/solidus_promotions/admin/shared/_number_with_currency.html.erb +20 -0
- data/lib/views/backend/solidus_promotions/admin/shared/_promotion_sub_menu.html.erb +14 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_boolean.html.erb +14 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_decimal.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_integer.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_password.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_string.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_text.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +2 -0
- data/lib/views/backend/solidus_promotions/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +2 -0
- data/solidus_promotions.gemspec +33 -0
- metadata +366 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class CreatePromotions < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
promotion_foreign_key = table_exists?(:spree_promotions) ? { to_table: :spree_promotions } : false
|
|
4
|
+
|
|
5
|
+
create_table :solidus_promotions_promotions do |t|
|
|
6
|
+
t.string :description
|
|
7
|
+
t.datetime :expires_at, precision: nil
|
|
8
|
+
t.datetime :starts_at, precision: nil
|
|
9
|
+
t.string :name
|
|
10
|
+
t.integer :usage_limit
|
|
11
|
+
t.boolean :advertise, default: false
|
|
12
|
+
t.string :path
|
|
13
|
+
t.integer :per_code_usage_limit
|
|
14
|
+
t.boolean :apply_automatically, default: false
|
|
15
|
+
t.integer :lane, null: false, default: 1
|
|
16
|
+
t.string :customer_label
|
|
17
|
+
t.datetime :deleted_at
|
|
18
|
+
t.references :original_promotion, type: :integer, index: { name: :index_original_promotion_id }, foreign_key: promotion_foreign_key
|
|
19
|
+
|
|
20
|
+
t.timestamps
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
add_index :solidus_promotions_promotions, :deleted_at
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class CreatePromotionBenefits < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
promotion_action_foreign_key = table_exists?(:spree_promotion_actions) ? { to_table: :spree_promotion_actions } : false
|
|
4
|
+
|
|
5
|
+
create_table :solidus_promotions_benefits do |t|
|
|
6
|
+
t.references :promotion, index: true, null: false, foreign_key: { to_table: :solidus_promotions_promotions }
|
|
7
|
+
t.string :type
|
|
8
|
+
t.text :preferences
|
|
9
|
+
t.references :original_promotion_action, type: :integer, index: { name: :index_original_promotion_action_id }, foreign_key: promotion_action_foreign_key
|
|
10
|
+
t.index [:id, :type], name: :index_solidus_promotions_benefits_on_id_and_type
|
|
11
|
+
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreatePromotionCategories < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :solidus_promotions_promotion_categories do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.string :code
|
|
6
|
+
|
|
7
|
+
t.timestamps
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
add_reference :solidus_promotions_promotions,
|
|
11
|
+
:promotion_category,
|
|
12
|
+
foreign_key: { to_table: :solidus_promotions_promotion_categories }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreatePromotionConditions < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :solidus_promotions_conditions do |t|
|
|
4
|
+
t.references :benefit,
|
|
5
|
+
foreign_key: { to_table: :solidus_promotions_benefits }
|
|
6
|
+
t.string :type
|
|
7
|
+
t.text :preferences
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class AddConditionJoinTables < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :solidus_promotions_condition_products, force: :cascade do |t|
|
|
4
|
+
t.references :product, type: :integer, index: true, null: false, foreign_key: { to_table: :spree_products }
|
|
5
|
+
t.references :condition, index: true, null: false, foreign_key: { to_table: :solidus_promotions_conditions }
|
|
6
|
+
|
|
7
|
+
t.timestamps
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
create_table :solidus_promotions_condition_taxons, force: :cascade do |t|
|
|
11
|
+
t.references :taxon, type: :integer, index: true, null: false, foreign_key: { to_table: :spree_taxons }
|
|
12
|
+
t.references :condition, index: true, null: false, foreign_key: { to_table: :solidus_promotions_conditions }
|
|
13
|
+
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
create_table :solidus_promotions_condition_users, force: :cascade do |t|
|
|
18
|
+
t.references :user, type: :integer, index: true, null: false, foreign_key: { to_table: Spree.user_class.table_name }
|
|
19
|
+
t.references :condition, index: true, null: false, foreign_key: { to_table: :solidus_promotions_conditions }
|
|
20
|
+
|
|
21
|
+
t.timestamps
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
create_table :solidus_promotions_condition_stores do |t|
|
|
25
|
+
t.references :store, type: :integer, index: true, null: false, foreign_key: { to_table: :spree_stores }
|
|
26
|
+
t.references :condition, index: true, null: false, foreign_key: { to_table: :solidus_promotions_conditions }
|
|
27
|
+
|
|
28
|
+
t.timestamps
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class CreatePromotionCodes < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :solidus_promotions_promotion_codes, force: :cascade do |t|
|
|
4
|
+
t.references :promotion, null: false, index: true, foreign_key: { to_table: :solidus_promotions_promotions }
|
|
5
|
+
t.string :value, null: false
|
|
6
|
+
t.timestamps
|
|
7
|
+
|
|
8
|
+
t.index ["value"], name: "index_solidus_promotions_promotion_codes_on_value", unique: true
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreatePromotionCodeBatches < ActiveRecord::Migration[7.0]
|
|
4
|
+
def change
|
|
5
|
+
create_table :solidus_promotions_promotion_code_batches do |t|
|
|
6
|
+
t.references :promotion, null: false, index: true, foreign_key: { to_table: :solidus_promotions_promotions }
|
|
7
|
+
t.string :base_code, null: false
|
|
8
|
+
t.integer :number_of_codes, null: false
|
|
9
|
+
t.string :join_characters, null: false, default: "_"
|
|
10
|
+
t.string :email
|
|
11
|
+
t.string :error
|
|
12
|
+
t.string :state, default: "pending"
|
|
13
|
+
t.timestamps precision: 6
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
add_column(
|
|
17
|
+
:solidus_promotions_promotion_codes,
|
|
18
|
+
:promotion_code_batch_id,
|
|
19
|
+
:bigint
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
add_foreign_key(
|
|
23
|
+
:solidus_promotions_promotion_codes,
|
|
24
|
+
:solidus_promotions_promotion_code_batches,
|
|
25
|
+
column: :promotion_code_batch_id
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
add_index(
|
|
29
|
+
:solidus_promotions_promotion_codes,
|
|
30
|
+
:promotion_code_batch_id,
|
|
31
|
+
name: "index_promotion_codes_on_promotion_code_batch_id"
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class CreateOrderPromotions < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :solidus_promotions_order_promotions do |t|
|
|
4
|
+
t.references :order, type: :integer, index: true, null: false, foreign_key: { to_table: :spree_orders }
|
|
5
|
+
t.references :promotion, index: true, null: false, foreign_key: { to_table: :solidus_promotions_promotions }
|
|
6
|
+
t.references :promotion_code, index: true, null: true, foreign_key: { to_table: :solidus_promotions_promotion_codes }
|
|
7
|
+
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreateShippingRateDiscounts < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :solidus_promotions_shipping_rate_discounts do |t|
|
|
4
|
+
t.references :benefit, type: :bigint, null: false, foreign_key: { to_table: :solidus_promotions_benefits }, index: { name: "index_shipping_rate_discounts_on_benefit_id" }
|
|
5
|
+
t.references :shipping_rate, type: :integer, null: false, foreign_key: { to_table: :spree_shipping_rates }, index: { name: "index_shipping_rate_discounts_on_shipping_rate_id" }
|
|
6
|
+
t.decimal :amount, precision: 10, scale: 2, null: false
|
|
7
|
+
t.string :label, null: false
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDbCommentsToOrderPromotions < ActiveRecord::Migration[6.1]
|
|
4
|
+
def up
|
|
5
|
+
if connection.supports_comments?
|
|
6
|
+
change_table_comment(:solidus_promotions_order_promotions, solidus_promotions_order_promotions_table_comment)
|
|
7
|
+
change_column_comment(:solidus_promotions_order_promotions, :order_id, order_id_comment)
|
|
8
|
+
change_column_comment(:solidus_promotions_order_promotions, :promotion_id, promotion_id_comment)
|
|
9
|
+
change_column_comment(:solidus_promotions_order_promotions, :promotion_code_id, promotion_code_id_comment)
|
|
10
|
+
change_column_comment(:solidus_promotions_order_promotions, :id, id_comment)
|
|
11
|
+
change_column_comment(:solidus_promotions_order_promotions, :created_at, created_at_comment)
|
|
12
|
+
change_column_comment(:solidus_promotions_order_promotions, :updated_at, updated_at_comment)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def solidus_promotions_order_promotions_table_comment
|
|
19
|
+
<<~COMMENT
|
|
20
|
+
Join table between spree_orders and solidus_promotions_promotions. One of two places that record whether a promotion is linked to an order.
|
|
21
|
+
The other place is the spree_adjustments table when the source of an adjustment is a SolidusPromotions::Benefit.
|
|
22
|
+
An entry here is created every time a promotion is explicitly linked to an order. No entry is created for automatic promotions.
|
|
23
|
+
COMMENT
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def order_id_comment
|
|
27
|
+
<<~COMMENT
|
|
28
|
+
Foreign key to the spree_orders table.
|
|
29
|
+
COMMENT
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def promotion_id_comment
|
|
33
|
+
<<~COMMENT
|
|
34
|
+
Foreign key to the solidus_promotions_promotions table.
|
|
35
|
+
COMMENT
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def promotion_code_id_comment
|
|
39
|
+
<<~COMMENT
|
|
40
|
+
Foreign key to the solidus_promotions_promotion_codes table. If a promotion code was used, records the promotion code.
|
|
41
|
+
COMMENT
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def id_comment
|
|
45
|
+
<<~COMMENT
|
|
46
|
+
Primary key of this table.
|
|
47
|
+
COMMENT
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def created_at_comment
|
|
51
|
+
<<~COMMENT
|
|
52
|
+
Timestamp indicating when this record was created.
|
|
53
|
+
COMMENT
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def updated_at_comment
|
|
57
|
+
<<~COMMENT
|
|
58
|
+
Timestamp indicating when this record was last updated.
|
|
59
|
+
COMMENT
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDbCommentsToConditionTaxons < ActiveRecord::Migration[6.1]
|
|
4
|
+
def up
|
|
5
|
+
if connection.supports_comments?
|
|
6
|
+
change_table_comment(:solidus_promotions_condition_taxons, solidus_promotions_condition_taxons_table_comment)
|
|
7
|
+
change_column_comment(:solidus_promotions_condition_taxons, :id, id_comment)
|
|
8
|
+
change_column_comment(:solidus_promotions_condition_taxons, :taxon_id, taxon_id_comment)
|
|
9
|
+
change_column_comment(:solidus_promotions_condition_taxons, :condition_id, condition_id_comment)
|
|
10
|
+
change_column_comment(:solidus_promotions_condition_taxons, :created_at, created_at_comment)
|
|
11
|
+
change_column_comment(:solidus_promotions_condition_taxons, :updated_at, updated_at_comment)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def solidus_promotions_condition_taxons_table_comment
|
|
18
|
+
<<~COMMENT
|
|
19
|
+
Join table between promotion conditions and taxons. Only used if the promotion rule's type is SolidusPromotions::Conditions::Taxon or
|
|
20
|
+
SolidusPromotions::Conditions::LineItemTaxon. Represents those taxons that the promotion rule matches on using its any/all/none
|
|
21
|
+
or include/exclude match policy.
|
|
22
|
+
COMMENT
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def id_comment
|
|
26
|
+
<<~COMMENT
|
|
27
|
+
Primary key of this table.
|
|
28
|
+
COMMENT
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def taxon_id_comment
|
|
32
|
+
<<~COMMENT
|
|
33
|
+
Foreign key to the spree_taxons table.
|
|
34
|
+
COMMENT
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def condition_id_comment
|
|
38
|
+
<<~COMMENT
|
|
39
|
+
Foreign key to the solidus_promotions_conditions table.
|
|
40
|
+
COMMENT
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def created_at_comment
|
|
44
|
+
<<~COMMENT
|
|
45
|
+
Timestamp indicating when this record was created.
|
|
46
|
+
COMMENT
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def updated_at_comment
|
|
50
|
+
<<~COMMENT
|
|
51
|
+
Timestamp indicating when this record was last updated.
|
|
52
|
+
COMMENT
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDbCommentsToConditions < ActiveRecord::Migration[6.1]
|
|
4
|
+
def up
|
|
5
|
+
if connection.supports_comments?
|
|
6
|
+
change_table_comment(:solidus_promotions_conditions, solidus_promotions_conditions_table_comment)
|
|
7
|
+
change_column_comment(:solidus_promotions_conditions, :id, id_comment)
|
|
8
|
+
change_column_comment(:solidus_promotions_conditions, :benefit_id, benefit_id_comment)
|
|
9
|
+
change_column_comment(:solidus_promotions_conditions, :type, type_comment)
|
|
10
|
+
change_column_comment(:solidus_promotions_conditions, :created_at, created_at_comment)
|
|
11
|
+
change_column_comment(:solidus_promotions_conditions, :updated_at, updated_at_comment)
|
|
12
|
+
change_column_comment(:solidus_promotions_conditions, :preferences, preferences_comment)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def solidus_promotions_conditions_table_comment
|
|
19
|
+
<<~COMMENT
|
|
20
|
+
Represents promotion conditions. A benefit may have many conditions, which determine whether the benefit is eligible.
|
|
21
|
+
All rules must be eligible for the benefit to be eligible. If there are no rules, the benefit is always eligible.
|
|
22
|
+
COMMENT
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def id_comment
|
|
26
|
+
<<~COMMENT
|
|
27
|
+
Primary key of this table.
|
|
28
|
+
COMMENT
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def benefit_id_comment
|
|
32
|
+
<<~COMMENT
|
|
33
|
+
Foreign key to the benefits table.
|
|
34
|
+
COMMENT
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def type_comment
|
|
38
|
+
<<~COMMENT
|
|
39
|
+
STI column. This represents which Ruby class to load when an entry of this table is loaded in Rails.
|
|
40
|
+
COMMENT
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def created_at_comment
|
|
44
|
+
<<~COMMENT
|
|
45
|
+
Timestamp indicating when this record was created.
|
|
46
|
+
COMMENT
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def updated_at_comment
|
|
50
|
+
<<~COMMENT
|
|
51
|
+
Timestamp indicating when this record was last updated.
|
|
52
|
+
COMMENT
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def preferences_comment
|
|
56
|
+
<<~COMMENT
|
|
57
|
+
Preferences for this condition. Serialized YAML column with preferences for this condition.
|
|
58
|
+
COMMENT
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDbCommentsToConditionUsers < ActiveRecord::Migration[6.1]
|
|
4
|
+
def up
|
|
5
|
+
if connection.supports_comments?
|
|
6
|
+
change_table_comment(:solidus_promotions_condition_users, solidus_promotions_condition_users_table_comment)
|
|
7
|
+
change_column_comment(:solidus_promotions_condition_users, :user_id, user_id_comment)
|
|
8
|
+
change_column_comment(:solidus_promotions_condition_users, :condition_id, condition_id_comment)
|
|
9
|
+
change_column_comment(:solidus_promotions_condition_users, :id, id_comment)
|
|
10
|
+
change_column_comment(:solidus_promotions_condition_users, :created_at, created_at_comment)
|
|
11
|
+
change_column_comment(:solidus_promotions_condition_users, :updated_at, updated_at_comment)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def solidus_promotions_condition_users_table_comment
|
|
18
|
+
<<~COMMENT
|
|
19
|
+
Join table between conditions and users. Used with conditions of type "SolidusPromotions::Conditions::User".
|
|
20
|
+
An entry here indicates that a promotion is eligible for the user ID specified here.
|
|
21
|
+
COMMENT
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def user_id_comment
|
|
25
|
+
<<~COMMENT
|
|
26
|
+
Foreign key to the users table.
|
|
27
|
+
COMMENT
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def condition_id_comment
|
|
31
|
+
<<~COMMENT
|
|
32
|
+
Foreign key to the conditions table.
|
|
33
|
+
COMMENT
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def id_comment
|
|
37
|
+
<<~COMMENT
|
|
38
|
+
Primary key of this table.
|
|
39
|
+
COMMENT
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def created_at_comment
|
|
43
|
+
<<~COMMENT
|
|
44
|
+
Timestamp indicating when this record was created.
|
|
45
|
+
COMMENT
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def updated_at_comment
|
|
49
|
+
<<~COMMENT
|
|
50
|
+
Timestamp indicating when this record was last updated.
|
|
51
|
+
COMMENT
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDbCommentsToPromotions < ActiveRecord::Migration[6.1]
|
|
4
|
+
def up
|
|
5
|
+
if connection.supports_comments?
|
|
6
|
+
change_table_comment(:solidus_promotions_promotions, solidus_promotions_promotions_table_comment)
|
|
7
|
+
change_column_comment(:solidus_promotions_promotions, :id, id_comment)
|
|
8
|
+
change_column_comment(:solidus_promotions_promotions, :description, description_comment)
|
|
9
|
+
change_column_comment(:solidus_promotions_promotions, :expires_at, expires_at_comment)
|
|
10
|
+
change_column_comment(:solidus_promotions_promotions, :starts_at, starts_at_comment)
|
|
11
|
+
change_column_comment(:solidus_promotions_promotions, :customer_label, customer_label_comment)
|
|
12
|
+
change_column_comment(:solidus_promotions_promotions, :usage_limit, usage_limit_comment)
|
|
13
|
+
change_column_comment(:solidus_promotions_promotions, :advertise, advertise_comment)
|
|
14
|
+
change_column_comment(:solidus_promotions_promotions, :path, path_comment)
|
|
15
|
+
change_column_comment(:solidus_promotions_promotions, :lane, lane_comment)
|
|
16
|
+
change_column_comment(:solidus_promotions_promotions, :name, name_comment)
|
|
17
|
+
change_column_comment(:solidus_promotions_promotions, :created_at, created_at_comment)
|
|
18
|
+
change_column_comment(:solidus_promotions_promotions, :updated_at, updated_at_comment)
|
|
19
|
+
change_column_comment(:solidus_promotions_promotions, :promotion_category_id, promotion_category_id_comment)
|
|
20
|
+
change_column_comment(:solidus_promotions_promotions, :per_code_usage_limit, per_code_usage_limit_comment)
|
|
21
|
+
change_column_comment(:solidus_promotions_promotions, :apply_automatically, apply_automatically_comment)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def solidus_promotions_promotions_table_comment
|
|
28
|
+
<<~COMMENT
|
|
29
|
+
Promotions are sets of rules and actions to discount (parts of) an order.
|
|
30
|
+
COMMENT
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def id_comment
|
|
34
|
+
<<~COMMENT
|
|
35
|
+
Primary key of this table.
|
|
36
|
+
COMMENT
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def description_comment
|
|
40
|
+
<<~COMMENT
|
|
41
|
+
The description of this promotion.
|
|
42
|
+
COMMENT
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def expires_at_comment
|
|
46
|
+
<<~COMMENT
|
|
47
|
+
Timestamp at which the promotion stops being eligible.
|
|
48
|
+
COMMENT
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def starts_at_comment
|
|
52
|
+
<<~COMMENT
|
|
53
|
+
Timestamp at which the promotion starts being eligible.
|
|
54
|
+
COMMENT
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def customer_label_comment
|
|
58
|
+
<<~COMMENT
|
|
59
|
+
The contents of this field will be replicated in the labels of adjustments created with it.
|
|
60
|
+
COMMENT
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def name_comment
|
|
64
|
+
<<~COMMENT
|
|
65
|
+
Admin name of the promotion.
|
|
66
|
+
COMMENT
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def usage_limit_comment
|
|
70
|
+
<<~COMMENT
|
|
71
|
+
How many times this promotion can be applied to orders globally.
|
|
72
|
+
COMMENT
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def advertise_comment
|
|
76
|
+
<<~COMMENT
|
|
77
|
+
Marks a promotion as advertised.
|
|
78
|
+
COMMENT
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def path_comment
|
|
82
|
+
<<~COMMENT
|
|
83
|
+
This could be used for applying a promotion based on a route the customer visits.
|
|
84
|
+
COMMENT
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def lane_comment
|
|
88
|
+
<<~COMMENT
|
|
89
|
+
Priority lane of this promotion.
|
|
90
|
+
COMMENT
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def created_at_comment
|
|
94
|
+
<<~COMMENT
|
|
95
|
+
Timestamp indicating when this record was created.
|
|
96
|
+
COMMENT
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def updated_at_comment
|
|
100
|
+
<<~COMMENT
|
|
101
|
+
Timestamp indicating when this record was last updated.
|
|
102
|
+
COMMENT
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def promotion_category_id_comment
|
|
106
|
+
<<~COMMENT
|
|
107
|
+
Foreign key to the solidus_promotions_promotion_categories table.
|
|
108
|
+
COMMENT
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def per_code_usage_limit_comment
|
|
112
|
+
<<~COMMENT
|
|
113
|
+
How many times this promotion can be used per promotion code.
|
|
114
|
+
COMMENT
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def apply_automatically_comment
|
|
118
|
+
<<~COMMENT
|
|
119
|
+
Whether this promotion applies automatically in the cart, as opposed to the promotion being activated through a promotion code
|
|
120
|
+
or a path (see above).
|
|
121
|
+
COMMENT
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDbCommentsToPromotionCodes < ActiveRecord::Migration[6.1]
|
|
4
|
+
def up
|
|
5
|
+
if connection.supports_comments?
|
|
6
|
+
change_table_comment(:solidus_promotions_promotion_codes, solidus_promotions_promotion_codes_table_comment)
|
|
7
|
+
change_column_comment(:solidus_promotions_promotion_codes, :id, id_comment)
|
|
8
|
+
change_column_comment(:solidus_promotions_promotion_codes, :promotion_id, promotion_id_comment)
|
|
9
|
+
change_column_comment(:solidus_promotions_promotion_codes, :value, value_comment)
|
|
10
|
+
change_column_comment(:solidus_promotions_promotion_codes, :created_at, created_at_comment)
|
|
11
|
+
change_column_comment(:solidus_promotions_promotion_codes, :updated_at, updated_at_comment)
|
|
12
|
+
change_column_comment(:solidus_promotions_promotion_codes, :promotion_code_batch_id, promotion_code_batch_id_comment)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def solidus_promotions_promotion_codes_table_comment
|
|
19
|
+
<<~COMMENT
|
|
20
|
+
Promotions can have many promotion codes. This table is a collection of those codes.
|
|
21
|
+
COMMENT
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def id_comment
|
|
25
|
+
<<~COMMENT
|
|
26
|
+
Primary key of this table.
|
|
27
|
+
COMMENT
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def promotion_id_comment
|
|
31
|
+
<<~COMMENT
|
|
32
|
+
Foreign key to the solidus_promotions_promotions table.
|
|
33
|
+
COMMENT
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def value_comment
|
|
37
|
+
<<~COMMENT
|
|
38
|
+
The actual code, such as "BOATLIFE" for example.
|
|
39
|
+
COMMENT
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def created_at_comment
|
|
43
|
+
<<~COMMENT
|
|
44
|
+
Timestamp indicating when this record was created.
|
|
45
|
+
COMMENT
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def updated_at_comment
|
|
49
|
+
<<~COMMENT
|
|
50
|
+
Timestamp indicating when this record was last updated.
|
|
51
|
+
COMMENT
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def promotion_code_batch_id_comment
|
|
55
|
+
<<~COMMENT
|
|
56
|
+
Foreign key to the solidus_promotions_promotion_code_batches table.
|
|
57
|
+
If this promotion code was created using a promotion code batch, links to the batch.
|
|
58
|
+
COMMENT
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDbCommentsToPromotionCodeBatches < ActiveRecord::Migration[6.1]
|
|
4
|
+
def up
|
|
5
|
+
if connection.supports_comments?
|
|
6
|
+
change_table_comment(:solidus_promotions_promotion_code_batches, solidus_promotions_promotion_code_batches_table_comment)
|
|
7
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :id, id_comment)
|
|
8
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :promotion_id, promotion_id_comment)
|
|
9
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :base_code, base_code_comment)
|
|
10
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :number_of_codes, number_of_codes_comment)
|
|
11
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :email, email_comment)
|
|
12
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :error, error_comment)
|
|
13
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :state, state_comment)
|
|
14
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :created_at, created_at_comment)
|
|
15
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :updated_at, updated_at_comment)
|
|
16
|
+
change_column_comment(:solidus_promotions_promotion_code_batches, :join_characters, join_characters_comment)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def solidus_promotions_promotion_code_batches_table_comment
|
|
23
|
+
<<~COMMENT
|
|
24
|
+
We allow creating a large number of promotion codes automatically through a background job. This table collects the input
|
|
25
|
+
for creating such a batch of promotion codes.
|
|
26
|
+
COMMENT
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def id_comment
|
|
30
|
+
<<~COMMENT
|
|
31
|
+
Primary key of this table.
|
|
32
|
+
COMMENT
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def promotion_id_comment
|
|
36
|
+
<<~COMMENT
|
|
37
|
+
Foreign key to the solidus_promotions_promotions table.
|
|
38
|
+
COMMENT
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def base_code_comment
|
|
42
|
+
<<~COMMENT
|
|
43
|
+
The base code of this promotion code batch, such as "BOATLIFE".
|
|
44
|
+
COMMENT
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def number_of_codes_comment
|
|
48
|
+
<<~COMMENT
|
|
49
|
+
How many codes should be generated.
|
|
50
|
+
COMMENT
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def email_comment
|
|
54
|
+
<<~COMMENT
|
|
55
|
+
After the batch has been created, or in the event of an error, notify this email address.
|
|
56
|
+
COMMENT
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def error_comment
|
|
60
|
+
<<~COMMENT
|
|
61
|
+
Error that has occurred during batch processing, if any.
|
|
62
|
+
COMMENT
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def state_comment
|
|
66
|
+
<<~COMMENT
|
|
67
|
+
What the state of the promotion code batch is:
|
|
68
|
+
- pending
|
|
69
|
+
- processing
|
|
70
|
+
- completed
|
|
71
|
+
COMMENT
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def created_at_comment
|
|
75
|
+
<<~COMMENT
|
|
76
|
+
Timestamp indicating when this record was created.
|
|
77
|
+
COMMENT
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def updated_at_comment
|
|
81
|
+
<<~COMMENT
|
|
82
|
+
Timestamp indicating when this record was last updated.
|
|
83
|
+
COMMENT
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def join_characters_comment
|
|
87
|
+
<<~COMMENT
|
|
88
|
+
What characters to use for joining the base code with the individual extension, such as "_" for creating "BOATLIFE_S3CR3T".
|
|
89
|
+
COMMENT
|
|
90
|
+
end
|
|
91
|
+
end
|