spree_pag_seguro 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/README.md +1 -1
  2. data/app/models/spree/pag_seguro_payment.rb +1 -0
  3. data/lib/spree_pag_seguro/engine.rb +1 -7
  4. data/spec/dummy/Rakefile +7 -0
  5. data/spec/dummy/app/assets/javascripts/admin/all.js +10 -0
  6. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  7. data/spec/dummy/app/assets/javascripts/store/all.js +10 -0
  8. data/spec/dummy/app/assets/stylesheets/admin/all.css +11 -0
  9. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  10. data/spec/dummy/app/assets/stylesheets/store/all.css +11 -0
  11. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  12. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  13. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  14. data/spec/dummy/config.ru +4 -0
  15. data/spec/dummy/config/application.rb +60 -0
  16. data/spec/dummy/config/boot.rb +6 -0
  17. data/spec/dummy/config/database.yml +18 -0
  18. data/spec/dummy/config/environment.rb +7 -0
  19. data/spec/dummy/config/environments/development.rb +30 -0
  20. data/spec/dummy/config/environments/production.rb +60 -0
  21. data/spec/dummy/config/environments/test.rb +39 -0
  22. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  23. data/spec/dummy/config/initializers/inflections.rb +10 -0
  24. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  25. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  26. data/spec/dummy/config/initializers/session_store.rb +8 -0
  27. data/spec/dummy/config/initializers/spree.rb +12 -0
  28. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  29. data/spec/dummy/config/locales/en.yml +5 -0
  30. data/spec/dummy/config/routes.rb +3 -0
  31. data/spec/dummy/config/spree.yml +2 -0
  32. data/spec/dummy/db/dummy_test +0 -0
  33. data/spec/dummy/db/migrate/20120301154050_spree_zero_nine_zero.rb +389 -0
  34. data/spec/dummy/db/migrate/20120301154051_create_indexes_for_inventory_units.rb +6 -0
  35. data/spec/dummy/db/migrate/20120301154052_add_count_on_hand_to_variants_and_products.rb +49 -0
  36. data/spec/dummy/db/migrate/20120301154053_change_taxons_to_nested_set.rb +46 -0
  37. data/spec/dummy/db/migrate/20120301154054_move_to_configurable_gateways.rb +54 -0
  38. data/spec/dummy/db/migrate/20120301154055_product_groups_and_scopes.rb +18 -0
  39. data/spec/dummy/db/migrate/20120301154056_add_open_id_authentication_tables.rb +15 -0
  40. data/spec/dummy/db/migrate/20120301154057_add_openid_field_to_users.rb +24 -0
  41. data/spec/dummy/db/migrate/20120301154058_change_preference_value_type.rb +10 -0
  42. data/spec/dummy/db/migrate/20120301154059_create_billing_integrations.rb +12 -0
  43. data/spec/dummy/db/migrate/20120301154060_charge_refactoring.rb +39 -0
  44. data/spec/dummy/db/migrate/20120301154061_add_some_indexes.rb +11 -0
  45. data/spec/dummy/db/migrate/20120301154062_checkout_state_machine.rb +5 -0
  46. data/spec/dummy/db/migrate/20120301154063_state_for_shipments.rb +5 -0
  47. data/spec/dummy/db/migrate/20120301154064_make_state_events_polymorphic.rb +12 -0
  48. data/spec/dummy/db/migrate/20120301154065_ship_address_id_for_checkouts.rb +5 -0
  49. data/spec/dummy/db/migrate/20120301154066_shipping_method_id_for_checkouts.rb +5 -0
  50. data/spec/dummy/db/migrate/20120301154067_creditcard_last_four_digits.rb +14 -0
  51. data/spec/dummy/db/migrate/20120301154068_populate_legacy_shipment_state.rb +15 -0
  52. data/spec/dummy/db/migrate/20120301154069_add_cost_price.rb +5 -0
  53. data/spec/dummy/db/migrate/20120301154070_shipment_id_for_inventory_units.rb +25 -0
  54. data/spec/dummy/db/migrate/20120301154071_cim_fields_for_creditcards.rb +6 -0
  55. data/spec/dummy/db/migrate/20120301154072_create_return_authorizations.rb +12 -0
  56. data/spec/dummy/db/migrate/20120301154073_add_return_authorization_to_inventory_units.rb +5 -0
  57. data/spec/dummy/db/migrate/20120301154074_create_trackers.rb +10 -0
  58. data/spec/dummy/db/migrate/20120301154075_creditcard_id_for_creditcard_txns.rb +5 -0
  59. data/spec/dummy/db/migrate/20120301154076_original_creditcard_txn_id_for_creditcard_txns.rb +5 -0
  60. data/spec/dummy/db/migrate/20120301154077_add_test_mode_to_billing_integration.rb +6 -0
  61. data/spec/dummy/db/migrate/20120301154078_create_products_product_groups.rb +8 -0
  62. data/spec/dummy/db/migrate/20120301154079_create_payment_methods.rb +16 -0
  63. data/spec/dummy/db/migrate/20120301154080_polymorphic_payments.rb +42 -0
  64. data/spec/dummy/db/migrate/20120301154081_change_payments_payment_method_to_belongs_to.rb +11 -0
  65. data/spec/dummy/db/migrate/20120301154082_assign_creditcard_txns_to_payment.rb +23 -0
  66. data/spec/dummy/db/migrate/20120301154083_sti_for_transactions.rb +15 -0
  67. data/spec/dummy/db/migrate/20120301154084_drop_billing_integrations.rb +16 -0
  68. data/spec/dummy/db/migrate/20120301154085_deleted_at_for_payment_methods.rb +14 -0
  69. data/spec/dummy/db/migrate/20120301154086_add_adjustments_index.rb +6 -0
  70. data/spec/dummy/db/migrate/20120301154087_fix_by_popularity.rb +9 -0
  71. data/spec/dummy/db/migrate/20120301154088_add_alt_text_to_images.rb +5 -0
  72. data/spec/dummy/db/migrate/20120301154089_fix_existing_coupon_credits.rb +13 -0
  73. data/spec/dummy/db/migrate/20120301154090_add_display_to_payment_methods.rb +5 -0
  74. data/spec/dummy/db/migrate/20120301154091_add_addresses_checkouts_indexes.rb +8 -0
  75. data/spec/dummy/db/migrate/20120301154092_add_icon_to_taxons.rb +17 -0
  76. data/spec/dummy/db/migrate/20120301154093_add_description_to_taxons.rb +11 -0
  77. data/spec/dummy/db/migrate/20120301154094_index_for_shipments_number.rb +5 -0
  78. data/spec/dummy/db/migrate/20120301154095_add_index_on_users_persistence_token.rb +5 -0
  79. data/spec/dummy/db/migrate/20120301154096_add_default_to_tax_categories.rb +5 -0
  80. data/spec/dummy/db/migrate/20120301154097_add_display_to_shipping_methods.rb +5 -0
  81. data/spec/dummy/db/migrate/20120301154098_rename_payment_method_display.rb +5 -0
  82. data/spec/dummy/db/migrate/20120301154099_rename_preferences_field.rb +5 -0
  83. data/spec/dummy/db/migrate/20120301154100_add_guest_flag.rb +5 -0
  84. data/spec/dummy/db/migrate/20120301154101_drop_order_token.rb +9 -0
  85. data/spec/dummy/db/migrate/20120301154102_payments_state_and_assigned_to_order_only.rb +14 -0
  86. data/spec/dummy/db/migrate/20120301154103_create_address_keys_for_order.rb +6 -0
  87. data/spec/dummy/db/migrate/20120301154104_payment_total_for_orders.rb +5 -0
  88. data/spec/dummy/db/migrate/20120301154105_shipping_method_id_for_orders.rb +5 -0
  89. data/spec/dummy/db/migrate/20120301154106_add_shipment_and_payment_state.rb +6 -0
  90. data/spec/dummy/db/migrate/20120301154107_refactor_adjustments.rb +29 -0
  91. data/spec/dummy/db/migrate/20120301154108_response_code_and_avs_response_for_payments.rb +6 -0
  92. data/spec/dummy/db/migrate/20120301154109_change_guest_flag_to_anonymous.rb +5 -0
  93. data/spec/dummy/db/migrate/20120301154110_email_for_orders.rb +5 -0
  94. data/spec/dummy/db/migrate/20120301154111_create_mail_methods.rb +10 -0
  95. data/spec/dummy/db/migrate/20120301154112_rename_frozen_to_locked.rb +5 -0
  96. data/spec/dummy/db/migrate/20120301154113_move_special_instructions_to_orders.rb +10 -0
  97. data/spec/dummy/db/migrate/20120301154114_create_log_entries.rb +11 -0
  98. data/spec/dummy/db/migrate/20120301154115_migrate_transactions_to_payment_state.rb +98 -0
  99. data/spec/dummy/db/migrate/20120301154116_delete_in_progress_orders.rb +19 -0
  100. data/spec/dummy/db/migrate/20120301154117_migrate_checkout_to_orders.rb +23 -0
  101. data/spec/dummy/db/migrate/20120301154118_remove_shipped_state.rb +12 -0
  102. data/spec/dummy/db/migrate/20120301154119_prevent_nil_payment_total.rb +8 -0
  103. data/spec/dummy/db/migrate/20120301154120_prevent_nil_email.rb +9 -0
  104. data/spec/dummy/db/migrate/20120301154121_generate_anonymous_users.rb +20 -0
  105. data/spec/dummy/db/migrate/20120301154122_update_order_state.rb +12 -0
  106. data/spec/dummy/db/migrate/20120301154123_cleanup_legacy_tables.rb +11 -0
  107. data/spec/dummy/db/migrate/20120301154124_remove_number_and_cvv_from_credicard.rb +11 -0
  108. data/spec/dummy/db/migrate/20120301154125_drop_anonymous_field_for_user.rb +9 -0
  109. data/spec/dummy/db/migrate/20120301154126_renamed_rma_cancelled_state.rb +9 -0
  110. data/spec/dummy/db/migrate/20120301154127_fix_problematic_index_names.rb +13 -0
  111. data/spec/dummy/db/migrate/20120301154128_add_position_to_variants.rb +5 -0
  112. data/spec/dummy/db/migrate/20120301154129_add_next_state_to_state_events.rb +5 -0
  113. data/spec/dummy/db/migrate/20120301154130_add_position_to_option_types.rb +5 -0
  114. data/spec/dummy/db/migrate/20120301154131_remove_trailing_slashes_in_taxon_permalinks.rb +19 -0
  115. data/spec/dummy/db/migrate/20120301154132_create_activators.rb +14 -0
  116. data/spec/dummy/db/migrate/20120301154133_eligible_for_adjustments.rb +5 -0
  117. data/spec/dummy/db/migrate/20120301154134_namespace_top_level_models.rb +52 -0
  118. data/spec/dummy/db/migrate/20120301154135_migrate_namespaced_polymorphic_models.rb +52 -0
  119. data/spec/dummy/db/migrate/20120301154136_make_adjustments_polymorphic.rb +9 -0
  120. data/spec/dummy/db/migrate/20120301154137_add_company_to_addresses.rb +5 -0
  121. data/spec/dummy/db/migrate/20120301154138_add_inc_tax_to_tax_rates.rb +5 -0
  122. data/spec/dummy/db/migrate/20120301154139_rename_inc_price_attribute.rb +5 -0
  123. data/spec/dummy/db/migrate/20120301154140_add_default_tax_zone.rb +5 -0
  124. data/spec/dummy/db/migrate/20120301154141_associate_shipping_methods_and_shipping_categories.rb +7 -0
  125. data/spec/dummy/db/migrate/20120301154142_add_match_rules_to_shipping_methods.rb +7 -0
  126. data/spec/dummy/db/migrate/20120301154143_new_preferences.rb +48 -0
  127. data/spec/dummy/db/migrate/20120301154144_add_deleted_at_to_tax_category.rb +5 -0
  128. data/spec/dummy/db/migrate/20120301154145_create_spree_payment_notifications.rb +12 -0
  129. data/spec/dummy/db/migrate/20120301154146_create_spree_pag_seguro_payments.rb +8 -0
  130. data/spec/dummy/db/schema.rb +569 -0
  131. data/spec/dummy/db/seeds.rb +11 -0
  132. data/spec/dummy/log/test.log +1073 -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. metadata +151 -16
@@ -0,0 +1,19 @@
1
+ class DeleteInProgressOrders < ActiveRecord::Migration
2
+ def up
3
+ execute("DELETE FROM orders WHERE orders.state = 'in_progress'")
4
+ delete_orphans('adjustments')
5
+ delete_orphans('checkouts')
6
+ delete_orphans('shipments')
7
+ delete_orphans('payments')
8
+ delete_orphans('line_items')
9
+ delete_orphans('inventory_units')
10
+ end
11
+
12
+ def down
13
+ end
14
+
15
+ private
16
+ def delete_orphans(table_name)
17
+ execute "DELETE FROM #{table_name} WHERE order_id NOT IN (SELECT id FROM orders)"
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ class MigrateCheckoutToOrders < ActiveRecord::Migration
2
+ def up
3
+ orders = select_all "SELECT * FROM orders"
4
+
5
+ orders.each do |order|
6
+ checkout = update_order(order)
7
+ execute "DELETE FROM checkouts WHERE id = #{checkout['id']}" if checkout
8
+ end
9
+ end
10
+
11
+ def down
12
+ end
13
+
14
+ private
15
+ def update_order(order)
16
+ checkout = select_one "SELECT * FROM checkouts WHERE order_id = #{order['id']}"
17
+
18
+ if checkout
19
+ execute "UPDATE orders SET email='#{checkout['email']}', bill_address_id = #{checkout['bill_address_id']}, ship_address_id = #{checkout['ship_address_id']} WHERE id = #{checkout['id']}"
20
+ end
21
+ checkout
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ class RemoveShippedState < ActiveRecord::Migration
2
+ def up
3
+ execute "UPDATE orders SET state = 'complete' WHERE state = 'shipped'"
4
+ shipments = select_all "SELECT shipments.id FROM shipments WHERE order_id IN (SELECT orders.id FROM orders WHERE orders.state = 'shipped')"
5
+ shipments.each do |shipment|
6
+ execute "UPDATE shipments SET state='shipped' WHERE id = #{shipment[:id]}"
7
+ end
8
+ end
9
+
10
+ def down
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ class PreventNilPaymentTotal < ActiveRecord::Migration
2
+ def up
3
+ execute "UPDATE orders SET payment_total = 0.0 WHERE payment_total IS NULL"
4
+ end
5
+
6
+ def down
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ class PreventNilEmail < ActiveRecord::Migration
2
+ def up
3
+ execute "UPDATE orders SET email = 'guest@example.com' WHERE email IS NULL"
4
+ execute "UPDATE orders SET email = 'guest@example.com' WHERE email = ''"
5
+ end
6
+
7
+ def down
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ class GenerateAnonymousUsers < ActiveRecord::Migration
2
+ def up
3
+ Spree::User.table_name = 'users'
4
+ Spree::Order.table_name = 'orders'
5
+
6
+ Spree::User.reset_column_information
7
+ Spree::Order.where(:user_id => nil).each do |order|
8
+ user = Spree::User.anonymous!
9
+ user.email ||= order.email
10
+ order.user = user
11
+ order.save!
12
+ end
13
+
14
+ Spree::User.table_name = 'spree_users'
15
+ Spree::Order.table_name = 'spree_orders'
16
+ end
17
+
18
+ def down
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ class UpdateOrderState < ActiveRecord::Migration
2
+ def up
3
+ Spree::Order.table_name = 'orders'
4
+
5
+ Spree::Order.all.map(&:update!)
6
+
7
+ Spree::Order.table_name = 'spree_orders'
8
+ end
9
+
10
+ def down
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class CleanupLegacyTables < ActiveRecord::Migration
2
+ def up
3
+ drop_table :checkouts
4
+ drop_table :transactions
5
+ drop_table :open_id_authentication_associations
6
+ drop_table :open_id_authentication_nonces
7
+ end
8
+
9
+ def down
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class RemoveNumberAndCvvFromCredicard < ActiveRecord::Migration
2
+ def up
3
+ remove_column :creditcards, :number
4
+ remove_column :creditcards, :verification_value
5
+ end
6
+
7
+ def down
8
+ add_column :creditcards, :verification_value, :text
9
+ add_column :creditcards, :number, :text
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class DropAnonymousFieldForUser < ActiveRecord::Migration
2
+ def up
3
+ remove_column :users, :anonymous
4
+ end
5
+
6
+ def down
7
+ add_column :users, :anonymous, :boolean
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class RenamedRmaCancelledState < ActiveRecord::Migration
2
+ def up
3
+ execute "UPDATE return_authorizations SET state = 'canceled' WHERE state = 'cancelled'"
4
+ end
5
+
6
+ def down
7
+ execute "UPDATE return_authorizations SET state = 'cancelled' WHERE state = 'canceled'"
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class FixProblematicIndexNames < ActiveRecord::Migration
2
+ def up
3
+ begin
4
+ remove_index :preferences, :name => 'index_preferences_on_owner_and_attribute_and_preference'
5
+ rescue ArgumentError
6
+ # ignore - already remove then
7
+ end
8
+ add_index :preferences, [:owner_id, :owner_type, :name, :group_id, :group_type], :name => 'ix_prefs_on_owner_attr_pref', :unique => true
9
+ end
10
+
11
+ def down
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ class AddPositionToVariants < ActiveRecord::Migration
2
+ def change
3
+ add_column :variants, :position, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddNextStateToStateEvents < ActiveRecord::Migration
2
+ def change
3
+ add_column :state_events, :next_state, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddPositionToOptionTypes < ActiveRecord::Migration
2
+ def change
3
+ add_column :option_types, :position, :integer, :null => false, :default => 0
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ class RemoveTrailingSlashesInTaxonPermalinks < ActiveRecord::Migration
2
+ def up
3
+ taxons = select_all "SELECT * FROM taxons"
4
+ taxons.each do |taxon|
5
+ if taxon['permalink'] && taxon['permalink'][-1..-1] == '/'
6
+ execute "UPDATE taxons SET permalink = '#{taxon['permalink'][0...-1]}' WHERE id = #{taxon['id']}"
7
+ end
8
+ end
9
+ end
10
+
11
+ def down
12
+ taxons = select_all "SELECT * FROM taxons"
13
+ taxons.each do |taxon|
14
+ if taxon['permalink'] && taxon['permalink'][-1..-1] != '/'
15
+ execute "UPDATE taxons SET permalink = '#{taxon['permalink'] + '/'}' WHERE id = #{taxon['id']}"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ class CreateActivators < ActiveRecord::Migration
2
+ def change
3
+ create_table :activators, :force => true do |t|
4
+ t.string :description
5
+ t.datetime :expires_at
6
+ t.datetime :created_at
7
+ t.datetime :updated_at
8
+ t.datetime :starts_at
9
+ t.string :name
10
+ t.string :event_name
11
+ t.string :type
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class EligibleForAdjustments < ActiveRecord::Migration
2
+ def change
3
+ add_column :adjustments, :eligible, :boolean, :default => true
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ class NamespaceTopLevelModels < ActiveRecord::Migration
2
+ def change
3
+ rename_table :activators, :spree_activators
4
+ rename_table :addresses, :spree_addresses
5
+ rename_table :adjustments, :spree_adjustments
6
+ rename_table :configurations, :spree_configurations
7
+ rename_table :assets, :spree_assets
8
+ rename_table :calculators, :spree_calculators
9
+ rename_table :countries, :spree_countries
10
+ rename_table :creditcards, :spree_creditcards
11
+ rename_table :gateways, :spree_gateways
12
+ rename_table :inventory_units, :spree_inventory_units
13
+ rename_table :line_items, :spree_line_items
14
+ rename_table :log_entries, :spree_log_entries
15
+ rename_table :mail_methods, :spree_mail_methods
16
+ rename_table :option_types, :spree_option_types
17
+ rename_table :option_values, :spree_option_values
18
+ rename_table :option_types_prototypes, :spree_option_types_prototypes
19
+ rename_table :option_values_variants, :spree_option_values_variants
20
+ rename_table :orders, :spree_orders
21
+ rename_table :payments, :spree_payments
22
+ rename_table :payment_methods, :spree_payment_methods
23
+ rename_table :preferences, :spree_preferences
24
+ rename_table :products, :spree_products
25
+ rename_table :product_groups, :spree_product_groups
26
+ rename_table :product_groups_products, :spree_product_groups_products
27
+ rename_table :product_option_types, :spree_product_option_types
28
+ rename_table :product_properties, :spree_product_properties
29
+ rename_table :product_scopes, :spree_product_scopes
30
+ rename_table :products_taxons, :spree_products_taxons
31
+ rename_table :properties, :spree_properties
32
+ rename_table :prototypes, :spree_prototypes
33
+ rename_table :properties_prototypes, :spree_properties_prototypes
34
+ rename_table :return_authorizations, :spree_return_authorizations
35
+ rename_table :roles, :spree_roles
36
+ rename_table :roles_users, :spree_roles_users
37
+ rename_table :shipments, :spree_shipments
38
+ rename_table :shipping_categories, :spree_shipping_categories
39
+ rename_table :shipping_methods, :spree_shipping_methods
40
+ rename_table :states, :spree_states
41
+ rename_table :state_events, :spree_state_events
42
+ rename_table :tax_categories, :spree_tax_categories
43
+ rename_table :tax_rates, :spree_tax_rates
44
+ rename_table :taxons, :spree_taxons
45
+ rename_table :taxonomies, :spree_taxonomies
46
+ rename_table :trackers, :spree_trackers
47
+ rename_table :users, :spree_users
48
+ rename_table :variants, :spree_variants
49
+ rename_table :zones, :spree_zones
50
+ rename_table :zone_members, :spree_zone_members
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ class MigrateNamespacedPolymorphicModels < ActiveRecord::Migration
2
+ def concat(str1, str2)
3
+ dbtype = Rails.configuration.database_configuration[Rails.env]['adapter'].to_sym
4
+
5
+ case dbtype
6
+ when :mysql, :mysql2
7
+ "CONCAT(#{str1}, #{str2})"
8
+ when :sqlserver
9
+ "(#{str1} + #{str2})"
10
+ else
11
+ "(#{str1} || #{str2})"
12
+ end
13
+ end
14
+
15
+ def update_column_data(table_names, column_name)
16
+ tables = Array.wrap(table_names)
17
+ tables.each do |table|
18
+ execute "UPDATE #{table} SET #{column_name} = #{concat("'Spree::'", column_name)}" +
19
+ " where #{column_name} NOT LIKE 'Spree::%' AND #{column_name} IS NOT NULL"
20
+ end
21
+ end
22
+
23
+ def replace_column_data(table_names, column_name)
24
+ tables = Array.wrap(table_names)
25
+ tables.each do |table|
26
+ execute "UPDATE #{table} SET #{column_name} = REPLACE(#{column_name}, 'Spree::', '') " +
27
+ " where #{column_name} LIKE 'Spree::%'"
28
+ end
29
+ end
30
+
31
+ def up
32
+ update_column_data(['spree_payments', 'spree_adjustments', 'spree_log_entries'], 'source_type')
33
+ update_column_data('spree_adjustments', 'originator_type')
34
+ update_column_data('spree_calculators', 'calculable_type')
35
+ update_column_data('spree_preferences', 'owner_type')
36
+ update_column_data('spree_state_events', 'stateful_type')
37
+ update_column_data(['spree_activators', 'spree_assets', 'spree_calculators', 'spree_configurations', 'spree_gateways', 'spree_payment_methods'], 'type')
38
+ update_column_data('spree_assets', 'viewable_type')
39
+ update_column_data('spree_zone_members', 'zoneable_type')
40
+ end
41
+
42
+ def down
43
+ replace_column_data(['spree_payments', 'spree_adjustments', 'spree_log_entries'], 'source_type')
44
+ replace_column_data('spree_adjustments', 'originator_type')
45
+ replace_column_data('spree_calculators', 'calculable_type')
46
+ replace_column_data('spree_preferences', 'owner_type')
47
+ replace_column_data('spree_state_events', 'stateful_type')
48
+ replace_column_data(['spree_activators', 'spree_assets', 'spree_calculators', 'spree_configurations', 'spree_gateways', 'spree_payment_methods'], 'type')
49
+ replace_column_data('spree_assets', 'viewable_type')
50
+ replace_column_data('spree_zone_members', 'zoneable_type')
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ class MakeAdjustmentsPolymorphic < ActiveRecord::Migration
2
+
3
+ def change
4
+ add_column :spree_adjustments, :adjustable_type, :string
5
+ rename_column :spree_adjustments, :order_id, :adjustable_id
6
+ execute "UPDATE spree_adjustments SET adjustable_type = 'Spree::Order'"
7
+ end
8
+
9
+ end
@@ -0,0 +1,5 @@
1
+ class AddCompanyToAddresses < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_addresses, :company, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddIncTaxToTaxRates < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_tax_rates, :inc_tax, :boolean, :default => false
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RenameIncPriceAttribute < ActiveRecord::Migration
2
+ def change
3
+ rename_column :spree_tax_rates, :inc_tax, :included_in_price
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddDefaultTaxZone < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_zones, :default_tax, :boolean, :default => false
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class AssociateShippingMethodsAndShippingCategories < ActiveRecord::Migration
2
+ def change
3
+ change_table :spree_shipping_methods do |t|
4
+ t.references :shipping_category
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class AddMatchRulesToShippingMethods < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_shipping_methods, :match_none, :boolean
4
+ add_column :spree_shipping_methods, :match_all, :boolean
5
+ add_column :spree_shipping_methods, :match_one, :boolean
6
+ end
7
+ end
@@ -0,0 +1,48 @@
1
+ require 'spree/core/preference_rescue'
2
+
3
+ class NewPreferences < ActiveRecord::Migration
4
+
5
+ def up
6
+ add_column :spree_preferences, :key, :string
7
+ add_column :spree_preferences, :value_type, :string
8
+ add_index :spree_preferences, :key, :unique => true
9
+
10
+ remove_index :spree_preferences, :name => 'ix_prefs_on_owner_attr_pref'
11
+
12
+ # remove old constraints for migration
13
+ change_column :spree_preferences, :name, :string, :null => true
14
+ change_column :spree_preferences, :owner_id, :integer, :null => true
15
+ change_column :spree_preferences, :owner_type, :string, :null => true
16
+ change_column :spree_preferences, :group_id, :integer, :null => true
17
+ change_column :spree_preferences, :group_type, :string, :null => true
18
+
19
+ cfgs = execute("select id, type from spree_configurations").to_a
20
+ execute("select id, owner_id, name from spree_preferences where owner_type = 'Spree::Configuration'").each do |pref|
21
+ configuration = cfgs.detect { |c| c[0].to_s == pref[1].to_s }
22
+
23
+ value_type = configuration[1].constantize.new.send "preferred_#{pref[2]}_type" rescue 'string'
24
+
25
+ execute "UPDATE spree_preferences set `key` = '#{configuration[1].underscore}/#{pref[2]}', `value_type` = '#{value_type}' where id = #{pref[0]}" rescue nil
26
+ end
27
+
28
+ # remove orphaned calculator preferences
29
+ Spree::Preference.where(:owner_type => 'Spree::Calculator').each do |preference|
30
+ preference.destroy unless Spree::Calculator.exists? preference.owner_id
31
+ end
32
+
33
+ Spree::PreferenceRescue.try
34
+
35
+ Spree::Preference.where(:value_type => nil).update_all(:value_type => 'string')
36
+ end
37
+
38
+ def down
39
+ remove_column :spree_preferences, :key
40
+ remove_column :spree_preferences, :value_type
41
+
42
+ add_column :spree_preferences, :name, :string
43
+ add_column :spree_preferences, :owner_id, :integer
44
+ add_column :spree_preferences, :owner_type, :string
45
+ add_column :spree_preferences, :group_id, :integer
46
+ add_column :spree_preferences, :group_type, :string
47
+ end
48
+ end