spree_flat_in_range 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/LICENSE +26 -0
  2. data/README.md +39 -0
  3. data/app/models/spree/calculator/flat_in_range.rb +21 -0
  4. data/config/locales/en.yml +5 -0
  5. data/lib/spree_flat_in_range.rb +21 -0
  6. data/spec/dummy/Rakefile +7 -0
  7. data/spec/dummy/app/assets/javascripts/admin/all.js +10 -0
  8. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  9. data/spec/dummy/app/assets/javascripts/store/all.js +10 -0
  10. data/spec/dummy/app/assets/stylesheets/admin/all.css +11 -0
  11. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  12. data/spec/dummy/app/assets/stylesheets/store/all.css +11 -0
  13. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  14. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  15. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  16. data/spec/dummy/config.ru +4 -0
  17. data/spec/dummy/config/application.rb +60 -0
  18. data/spec/dummy/config/boot.rb +6 -0
  19. data/spec/dummy/config/database.yml +18 -0
  20. data/spec/dummy/config/environment.rb +7 -0
  21. data/spec/dummy/config/environments/development.rb +30 -0
  22. data/spec/dummy/config/environments/production.rb +60 -0
  23. data/spec/dummy/config/environments/test.rb +39 -0
  24. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  25. data/spec/dummy/config/initializers/inflections.rb +10 -0
  26. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  27. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  28. data/spec/dummy/config/initializers/session_store.rb +8 -0
  29. data/spec/dummy/config/initializers/spree.rb +12 -0
  30. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  31. data/spec/dummy/config/locales/en.yml +5 -0
  32. data/spec/dummy/config/routes.rb +3 -0
  33. data/spec/dummy/config/spree.yml +2 -0
  34. data/spec/dummy/db/dummy_test +0 -0
  35. data/spec/dummy/db/migrate/20120218160357_spree_zero_nine_zero.rb +389 -0
  36. data/spec/dummy/db/migrate/20120218160358_create_indexes_for_inventory_units.rb +6 -0
  37. data/spec/dummy/db/migrate/20120218160359_add_count_on_hand_to_variants_and_products.rb +49 -0
  38. data/spec/dummy/db/migrate/20120218160360_change_taxons_to_nested_set.rb +46 -0
  39. data/spec/dummy/db/migrate/20120218160361_move_to_configurable_gateways.rb +54 -0
  40. data/spec/dummy/db/migrate/20120218160362_product_groups_and_scopes.rb +18 -0
  41. data/spec/dummy/db/migrate/20120218160363_add_open_id_authentication_tables.rb +15 -0
  42. data/spec/dummy/db/migrate/20120218160364_add_openid_field_to_users.rb +24 -0
  43. data/spec/dummy/db/migrate/20120218160365_change_preference_value_type.rb +10 -0
  44. data/spec/dummy/db/migrate/20120218160366_create_billing_integrations.rb +12 -0
  45. data/spec/dummy/db/migrate/20120218160367_charge_refactoring.rb +39 -0
  46. data/spec/dummy/db/migrate/20120218160368_add_some_indexes.rb +11 -0
  47. data/spec/dummy/db/migrate/20120218160369_checkout_state_machine.rb +5 -0
  48. data/spec/dummy/db/migrate/20120218160370_state_for_shipments.rb +5 -0
  49. data/spec/dummy/db/migrate/20120218160371_make_state_events_polymorphic.rb +12 -0
  50. data/spec/dummy/db/migrate/20120218160372_ship_address_id_for_checkouts.rb +5 -0
  51. data/spec/dummy/db/migrate/20120218160373_shipping_method_id_for_checkouts.rb +5 -0
  52. data/spec/dummy/db/migrate/20120218160374_creditcard_last_four_digits.rb +14 -0
  53. data/spec/dummy/db/migrate/20120218160375_populate_legacy_shipment_state.rb +15 -0
  54. data/spec/dummy/db/migrate/20120218160376_add_cost_price.rb +5 -0
  55. data/spec/dummy/db/migrate/20120218160377_shipment_id_for_inventory_units.rb +25 -0
  56. data/spec/dummy/db/migrate/20120218160378_cim_fields_for_creditcards.rb +6 -0
  57. data/spec/dummy/db/migrate/20120218160379_create_return_authorizations.rb +12 -0
  58. data/spec/dummy/db/migrate/20120218160380_add_return_authorization_to_inventory_units.rb +5 -0
  59. data/spec/dummy/db/migrate/20120218160381_create_trackers.rb +10 -0
  60. data/spec/dummy/db/migrate/20120218160382_creditcard_id_for_creditcard_txns.rb +5 -0
  61. data/spec/dummy/db/migrate/20120218160383_original_creditcard_txn_id_for_creditcard_txns.rb +5 -0
  62. data/spec/dummy/db/migrate/20120218160384_add_test_mode_to_billing_integration.rb +6 -0
  63. data/spec/dummy/db/migrate/20120218160385_create_products_product_groups.rb +8 -0
  64. data/spec/dummy/db/migrate/20120218160386_create_payment_methods.rb +16 -0
  65. data/spec/dummy/db/migrate/20120218160387_polymorphic_payments.rb +42 -0
  66. data/spec/dummy/db/migrate/20120218160388_change_payments_payment_method_to_belongs_to.rb +11 -0
  67. data/spec/dummy/db/migrate/20120218160389_assign_creditcard_txns_to_payment.rb +23 -0
  68. data/spec/dummy/db/migrate/20120218160390_sti_for_transactions.rb +15 -0
  69. data/spec/dummy/db/migrate/20120218160391_drop_billing_integrations.rb +16 -0
  70. data/spec/dummy/db/migrate/20120218160392_deleted_at_for_payment_methods.rb +14 -0
  71. data/spec/dummy/db/migrate/20120218160393_add_adjustments_index.rb +6 -0
  72. data/spec/dummy/db/migrate/20120218160394_fix_by_popularity.rb +9 -0
  73. data/spec/dummy/db/migrate/20120218160395_add_alt_text_to_images.rb +5 -0
  74. data/spec/dummy/db/migrate/20120218160396_fix_existing_coupon_credits.rb +13 -0
  75. data/spec/dummy/db/migrate/20120218160397_add_display_to_payment_methods.rb +5 -0
  76. data/spec/dummy/db/migrate/20120218160398_add_addresses_checkouts_indexes.rb +8 -0
  77. data/spec/dummy/db/migrate/20120218160399_add_icon_to_taxons.rb +17 -0
  78. data/spec/dummy/db/migrate/20120218160400_add_description_to_taxons.rb +11 -0
  79. data/spec/dummy/db/migrate/20120218160401_index_for_shipments_number.rb +5 -0
  80. data/spec/dummy/db/migrate/20120218160402_add_index_on_users_persistence_token.rb +5 -0
  81. data/spec/dummy/db/migrate/20120218160403_add_default_to_tax_categories.rb +5 -0
  82. data/spec/dummy/db/migrate/20120218160404_add_display_to_shipping_methods.rb +5 -0
  83. data/spec/dummy/db/migrate/20120218160405_rename_payment_method_display.rb +5 -0
  84. data/spec/dummy/db/migrate/20120218160406_rename_preferences_field.rb +5 -0
  85. data/spec/dummy/db/migrate/20120218160407_add_guest_flag.rb +5 -0
  86. data/spec/dummy/db/migrate/20120218160408_drop_order_token.rb +9 -0
  87. data/spec/dummy/db/migrate/20120218160409_payments_state_and_assigned_to_order_only.rb +14 -0
  88. data/spec/dummy/db/migrate/20120218160410_create_address_keys_for_order.rb +6 -0
  89. data/spec/dummy/db/migrate/20120218160411_payment_total_for_orders.rb +5 -0
  90. data/spec/dummy/db/migrate/20120218160412_shipping_method_id_for_orders.rb +5 -0
  91. data/spec/dummy/db/migrate/20120218160413_add_shipment_and_payment_state.rb +6 -0
  92. data/spec/dummy/db/migrate/20120218160414_refactor_adjustments.rb +29 -0
  93. data/spec/dummy/db/migrate/20120218160415_response_code_and_avs_response_for_payments.rb +6 -0
  94. data/spec/dummy/db/migrate/20120218160416_change_guest_flag_to_anonymous.rb +5 -0
  95. data/spec/dummy/db/migrate/20120218160417_email_for_orders.rb +5 -0
  96. data/spec/dummy/db/migrate/20120218160418_create_mail_methods.rb +10 -0
  97. data/spec/dummy/db/migrate/20120218160419_rename_frozen_to_locked.rb +5 -0
  98. data/spec/dummy/db/migrate/20120218160420_move_special_instructions_to_orders.rb +10 -0
  99. data/spec/dummy/db/migrate/20120218160421_create_log_entries.rb +11 -0
  100. data/spec/dummy/db/migrate/20120218160422_migrate_transactions_to_payment_state.rb +98 -0
  101. data/spec/dummy/db/migrate/20120218160423_delete_in_progress_orders.rb +19 -0
  102. data/spec/dummy/db/migrate/20120218160424_migrate_checkout_to_orders.rb +23 -0
  103. data/spec/dummy/db/migrate/20120218160425_remove_shipped_state.rb +12 -0
  104. data/spec/dummy/db/migrate/20120218160426_prevent_nil_payment_total.rb +8 -0
  105. data/spec/dummy/db/migrate/20120218160427_prevent_nil_email.rb +9 -0
  106. data/spec/dummy/db/migrate/20120218160428_generate_anonymous_users.rb +20 -0
  107. data/spec/dummy/db/migrate/20120218160429_update_order_state.rb +12 -0
  108. data/spec/dummy/db/migrate/20120218160430_cleanup_legacy_tables.rb +11 -0
  109. data/spec/dummy/db/migrate/20120218160431_remove_number_and_cvv_from_credicard.rb +11 -0
  110. data/spec/dummy/db/migrate/20120218160432_drop_anonymous_field_for_user.rb +9 -0
  111. data/spec/dummy/db/migrate/20120218160433_renamed_rma_cancelled_state.rb +9 -0
  112. data/spec/dummy/db/migrate/20120218160434_fix_problematic_index_names.rb +13 -0
  113. data/spec/dummy/db/migrate/20120218160435_add_position_to_variants.rb +5 -0
  114. data/spec/dummy/db/migrate/20120218160436_add_next_state_to_state_events.rb +5 -0
  115. data/spec/dummy/db/migrate/20120218160437_add_position_to_option_types.rb +5 -0
  116. data/spec/dummy/db/migrate/20120218160438_remove_trailing_slashes_in_taxon_permalinks.rb +19 -0
  117. data/spec/dummy/db/migrate/20120218160439_create_activators.rb +14 -0
  118. data/spec/dummy/db/migrate/20120218160440_eligible_for_adjustments.rb +5 -0
  119. data/spec/dummy/db/migrate/20120218160441_namespace_top_level_models.rb +52 -0
  120. data/spec/dummy/db/migrate/20120218160442_migrate_namespaced_polymorphic_models.rb +52 -0
  121. data/spec/dummy/db/migrate/20120218160443_make_adjustments_polymorphic.rb +9 -0
  122. data/spec/dummy/db/migrate/20120218160444_add_company_to_addresses.rb +5 -0
  123. data/spec/dummy/db/migrate/20120218160445_add_inc_tax_to_tax_rates.rb +5 -0
  124. data/spec/dummy/db/migrate/20120218160446_rename_inc_price_attribute.rb +5 -0
  125. data/spec/dummy/db/migrate/20120218160447_add_default_tax_zone.rb +5 -0
  126. data/spec/dummy/db/migrate/20120218160448_associate_shipping_methods_and_shipping_categories.rb +7 -0
  127. data/spec/dummy/db/migrate/20120218160449_add_match_rules_to_shipping_methods.rb +7 -0
  128. data/spec/dummy/db/migrate/20120218160450_new_preferences.rb +48 -0
  129. data/spec/dummy/db/migrate/20120218160451_add_deleted_at_to_tax_category.rb +5 -0
  130. data/spec/dummy/db/schema.rb +553 -0
  131. data/spec/dummy/db/seeds.rb +11 -0
  132. data/spec/dummy/log/test.log +1136 -0
  133. data/spec/dummy/public/404.html +26 -0
  134. data/spec/dummy/public/422.html +26 -0
  135. data/spec/dummy/public/500.html +26 -0
  136. data/spec/dummy/public/favicon.ico +0 -0
  137. data/spec/dummy/script/rails +6 -0
  138. data/spec/dummy/spec/dummy/script/rails +6 -0
  139. data/spec/flat_in_range_spec.rb +56 -0
  140. data/spec/spec_helper.rb +32 -0
  141. metadata +428 -0
@@ -0,0 +1,5 @@
1
+ class CreditcardIdForCreditcardTxns < ActiveRecord::Migration
2
+ def change
3
+ add_column :creditcard_txns, :creditcard_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class OriginalCreditcardTxnIdForCreditcardTxns < ActiveRecord::Migration
2
+ def change
3
+ add_column :creditcard_txns, :original_creditcard_txn_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddTestModeToBillingIntegration < ActiveRecord::Migration
2
+ def change
3
+ add_column :billing_integrations, :test_mode, :boolean, :default => true
4
+ add_column :billing_integrations, :server, :string, :default => 'test'
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ class CreateProductsProductGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :product_groups_products, :id => false do |t|
4
+ t.references :product
5
+ t.references :product_group
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ class CreatePaymentMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :payment_methods do |t|
4
+ t.string :type, :name
5
+ t.text :description
6
+ t.boolean :active, :default => true
7
+ t.string :environment, :default => 'development'
8
+
9
+ t.timestamps
10
+ end
11
+ # TODO - also migrate any legacy configurations for gateways and billing integrations before dropping the old tables
12
+ # we probably also need to do this inside the payment_gateway extension b/c table won't exist yet in fresh bootstrap
13
+ #drop_table :billing_integrations
14
+ #drop_table :gateways
15
+ end
16
+ end
@@ -0,0 +1,42 @@
1
+ # Legacy table support
2
+ class Checkout < ActiveRecord::Base; end;
3
+
4
+ class PolymorphicPayments < ActiveRecord::Migration
5
+ def up
6
+ remove_column :payments, :type
7
+ remove_column :payments, :creditcard_id
8
+ rename_column :payments, :order_id, :payable_id
9
+ change_table :payments do |t|
10
+ t.string :payable_type, :payment_method
11
+ t.references :source, :polymorphic => true
12
+ end
13
+ execute "UPDATE payments SET payable_type = 'Order'"
14
+
15
+ Spree::Creditcard.table_name = 'creditcards'
16
+
17
+ Spree::Creditcard.all.each do |creditcard|
18
+ if checkout = Checkout.find_by_id(creditcard.checkout_id) and checkout.order
19
+ if payment = checkout.order.payments.first
20
+ execute "UPDATE payments SET source_type = 'Creditcard', source_id = #{creditcard.id} WHERE id = #{payment.id}"
21
+ end
22
+ end
23
+ end
24
+
25
+ Spree::Creditcard.table_name = 'spree_creditcards'
26
+
27
+ remove_column :creditcards, :checkout_id
28
+ end
29
+
30
+ def down
31
+ add_column :creditcards, :checkout_id, :integer
32
+ change_table :payments do |t|
33
+ t.remove :payable_type
34
+ t.remove :payment_method
35
+ t.remove :source_id
36
+ t.remove :source_type
37
+ end
38
+ rename_column :payments, :payable_id, :order_id
39
+ add_column :payments, :creditcard_id, :integer
40
+ add_column :payments, :type, :string
41
+ end
42
+ end
@@ -0,0 +1,11 @@
1
+ class ChangePaymentsPaymentMethodToBelongsTo < ActiveRecord::Migration
2
+ def up
3
+ remove_column :payments, :payment_method
4
+ add_column :payments, :payment_method_id, :integer
5
+ end
6
+
7
+ def down
8
+ add_column :payments, :payment_method, :string
9
+ remove_column :payments, :payment_method_id
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ class AssignCreditcardTxnsToPayment < ActiveRecord::Migration
2
+ def up
3
+ add_column :creditcard_txns, :payment_id, :integer
4
+
5
+ # Temporarily set back to creditcards
6
+ Spree::Creditcard.table_name = 'creditcards'
7
+
8
+ ActiveRecord::Base.connection.select_all('SELECT * FROM creditcard_txns').each do |txn_attrs|
9
+ if creditcard = Spree::Creditcard.find_by_id(txn_attrs['creditcard_id']) and creditcard.payments.first
10
+ execute "UPDATE creditcard_txns SET payment_id = #{creditcard.payments.first.id} WHERE id = #{txn_attrs['id']}"
11
+ end
12
+ end
13
+
14
+ Spree::Creditcard.table_name = 'spree_creditcards'
15
+
16
+ remove_column :creditcard_txns, :creditcard_payment_id
17
+ end
18
+
19
+ def down
20
+ remove_column :creditcard_txns, :payment_id
21
+ add_column :creditcard_txns, :creditcard_payment_id, :integer
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ class StiForTransactions < ActiveRecord::Migration
2
+ def up
3
+ rename_table :creditcard_txns, :transactions
4
+ add_column :transactions, :type, :string
5
+ remove_column :transactions, :creditcard_id
6
+
7
+ execute "UPDATE transactions SET type = 'CreditcardTxn'"
8
+ end
9
+
10
+ def down
11
+ rename_table :transactions, :creditcard_txns
12
+ remove_column :transactions, :type
13
+ add_column :transactions, :creditcard_id, :integer
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ class DropBillingIntegrations < ActiveRecord::Migration
2
+ def up
3
+ drop_table :billing_integrations
4
+ end
5
+
6
+ def down
7
+ create_table :billing_integrations do |t|
8
+ t.string :type, :name
9
+ t.text :description
10
+ t.boolean :active, :default => true
11
+ t.string :environment, :default => 'development'
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ class DeletedAtForPaymentMethods < ActiveRecord::Migration
2
+ def up
3
+ change_table :payment_methods do |t|
4
+ t.timestamp :deleted_at, :default => nil
5
+ end
6
+ end
7
+
8
+ def down
9
+ remove_column :payments_methods, :column_name
10
+ change_table :payment_methods do |t|
11
+ t.remove :deleted_at
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ class AddAdjustmentsIndex < ActiveRecord::Migration
2
+ def change
3
+ add_index :adjustments, :order_id
4
+ end
5
+ end
6
+
@@ -0,0 +1,9 @@
1
+ class FixByPopularity < ActiveRecord::Migration
2
+ def up
3
+ execute("UPDATE product_scopes SET name='descend_by_popularity' WHERE name='by_popularity'")
4
+ end
5
+
6
+ def down
7
+ execute("UPDATE product_scopes SET name='by_popularity' WHERE name='descend_by_popularity'")
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class AddAltTextToImages < ActiveRecord::Migration
2
+ def change
3
+ add_column :assets, :alt, :text
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class Adjustment < ActiveRecord::Base; end;
2
+
3
+ class FixExistingCouponCredits < ActiveRecord::Migration
4
+ def up
5
+ execute("UPDATE adjustments SET type='PromotionCredit' WHERE type='CouponCredit'")
6
+ execute("UPDATE adjustments SET adjustment_source_type='Promotion' WHERE adjustment_source_type='Coupon'")
7
+ end
8
+
9
+ def down
10
+ execute("UPDATE adjustments SET adjustment_source_type='Coupon' WHERE adjustment_source_type='Promotion'")
11
+ execute("UPDATE adjustments SET type='CouponCredit' WHERE type='PromotionCredit'")
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ class AddDisplayToPaymentMethods < ActiveRecord::Migration
2
+ def change
3
+ add_column :payment_methods, :display, :string, :default => nil
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ class AddAddressesCheckoutsIndexes < ActiveRecord::Migration
2
+ def change
3
+ add_index :addresses, :firstname
4
+ add_index :addresses, :lastname
5
+ add_index :checkouts, :order_id
6
+ add_index :checkouts, :bill_address_id
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ class AddIconToTaxons < ActiveRecord::Migration
2
+ def up
3
+ # skip this migration if the attribute already exists because of advanced taxon extension
4
+ return if column_exists?(:taxons, :icon_file_name)
5
+ add_column :taxons, :icon_file_name, :string
6
+ add_column :taxons, :icon_content_type, :string
7
+ add_column :taxons, :icon_file_size, :integer
8
+ add_column :taxons, :icon_updated_at, :datetime
9
+ end
10
+
11
+ def down
12
+ remove_column :taxons, :icon_file_name
13
+ remove_column :taxons, :icon_content_type
14
+ remove_column :taxons, :icon_file_size
15
+ remove_column :taxons, :icon_updated_at
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ class AddDescriptionToTaxons < ActiveRecord::Migration
2
+ def up
3
+ # skip this migration if the attribute already exists because of advanced taxon extension
4
+ return if column_exists?(:taxons, :description)
5
+ add_column :taxons, :description, :text
6
+ end
7
+
8
+ def down
9
+ remove_column :taxons, :description
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class IndexForShipmentsNumber < ActiveRecord::Migration
2
+ def change
3
+ add_index :shipments, :number
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddIndexOnUsersPersistenceToken < ActiveRecord::Migration
2
+ def change
3
+ add_index :users, :persistence_token
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddDefaultToTaxCategories < ActiveRecord::Migration
2
+ def change
3
+ add_column :tax_categories, :is_default, :boolean, :default => false
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddDisplayToShippingMethods < ActiveRecord::Migration
2
+ def change
3
+ add_column :shipping_methods, :display_on, :string, :default => nil
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RenamePaymentMethodDisplay < ActiveRecord::Migration
2
+ def change
3
+ rename_column :payment_methods, :display, :display_on
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RenamePreferencesField < ActiveRecord::Migration
2
+ def change
3
+ rename_column :preferences, :attribute, :name
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddGuestFlag < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :guest, :boolean
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class DropOrderToken < ActiveRecord::Migration
2
+ def up
3
+ remove_column :orders, :token
4
+ end
5
+
6
+ def down
7
+ add_column :orders, :token, :string
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class PaymentsStateAndAssignedToOrderOnly < ActiveRecord::Migration
2
+ def up
3
+ # TODO: migrate existing payments
4
+ rename_column :payments, :payable_id, :order_id
5
+ remove_column :payments, :payable_type
6
+ add_column :payments, :state, :string
7
+ end
8
+
9
+ def down
10
+ remove_column :payments, :state
11
+ add_column :payments, :payable_type, :string
12
+ rename_column :payments, :order_id, :payable_id
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ class CreateAddressKeysForOrder < ActiveRecord::Migration
2
+ def change
3
+ add_column :orders, :bill_address_id, :integer
4
+ add_column :orders, :ship_address_id, :integer
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class PaymentTotalForOrders < ActiveRecord::Migration
2
+ def change
3
+ add_column :orders, :payment_total, :decimal, :precision => 8, :scale => 2, :default => 0.0
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class ShippingMethodIdForOrders < ActiveRecord::Migration
2
+ def change
3
+ add_column :orders, :shipping_method_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddShipmentAndPaymentState < ActiveRecord::Migration
2
+ def change
3
+ add_column :orders, :shipment_state, :string
4
+ add_column :orders, :payment_state, :string
5
+ end
6
+ end
@@ -0,0 +1,29 @@
1
+ class RefactorAdjustments < ActiveRecord::Migration
2
+ def up
3
+ change_table :adjustments do |t|
4
+ t.boolean :mandatory
5
+ t.boolean :frozen
6
+ t.rename :adjustment_source_id, :source_id
7
+ t.rename :adjustment_source_type, :source_type
8
+ t.references :originator
9
+ t.string :originator_type
10
+ t.remove :type
11
+ t.rename :description, :label
12
+ t.remove :position
13
+ end
14
+ end
15
+
16
+ def down
17
+ change_table :adjustments do |t|
18
+ t.integer :position
19
+ t.rename :label, :description
20
+ t.string :type
21
+ t.remove :originator_type
22
+ t.remove :originator_id
23
+ t.rename :source_type, :adjustment_source_type
24
+ t.rename :source_id, :adjustment_source_id
25
+ t.remove :frozen
26
+ t.remove :mandatory
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ class ResponseCodeAndAvsResponseForPayments < ActiveRecord::Migration
2
+ def change
3
+ add_column :payments, :response_code, :string
4
+ add_column :payments, :avs_response, :string
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class ChangeGuestFlagToAnonymous < ActiveRecord::Migration
2
+ def change
3
+ rename_column :users, :guest, :anonymous
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class EmailForOrders < ActiveRecord::Migration
2
+ def change
3
+ add_column :orders, :email, :string
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class CreateMailMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :mail_methods do |t|
4
+ t.string :environment
5
+ t.boolean :active, :default => true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class RenameFrozenToLocked < ActiveRecord::Migration
2
+ def change
3
+ rename_column :adjustments, :frozen, :locked
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class MoveSpecialInstructionsToOrders < ActiveRecord::Migration
2
+ def up
3
+ add_column :orders, :special_instructions, :text
4
+ execute "UPDATE orders SET special_instructions = (SELECT special_instructions FROM checkouts WHERE order_id = orders.id)"
5
+ end
6
+
7
+ def down
8
+ remove_column :orders, :special_instructions, :text
9
+ end
10
+ end