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,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ mount Spree::Core::Engine => "/"
3
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ version: 1.0.0
Binary file
@@ -0,0 +1,389 @@
1
+ class SpreeZeroNineZero < ActiveRecord::Migration
2
+ # This is a legacy migration consolidating all of the database changes needed as of Spree 0.9.0
3
+ # (See http://railsdog.lighthouseapp.com/projects/31096-spree/tickets/772)
4
+
5
+ def change
6
+ create_table :addresses, :force => true do |t|
7
+ t.string :firstname, :lastname, :address1, :address2, :city,
8
+ :zipcode, :phone, :state_name, :alternative_phone
9
+ t.references :state
10
+ t.references :country
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ create_table :adjustments, :force => true do |t|
16
+ t.integer :position, :adjustment_source_id
17
+ t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
18
+ t.string :type, :description, :adjustment_source_type, :secondary_type
19
+ t.references :order
20
+
21
+ t.timestamps
22
+ end
23
+
24
+ create_table :assets, :force => true do |t|
25
+ t.integer :viewable_id, :attachment_width, :attachment_height,
26
+ :attachment_size, :position
27
+ t.string :viewable_type, :limit => 50
28
+ t.string :attachment_content_type, :attachment_file_name
29
+ t.string :type, :limit => 75
30
+ t.datetime :attachment_updated_at
31
+ end
32
+
33
+ create_table :calculators, :force => true do |t|
34
+ t.string :type
35
+ t.integer :calculable_id, :null => false
36
+ t.string :calculable_type, :null => false
37
+
38
+ t.timestamps
39
+ end
40
+
41
+ create_table :checkouts, :force => true do |t|
42
+ t.references :order
43
+ t.string :email, :ip_address
44
+ t.text :special_instructions
45
+ t.integer :bill_address_id
46
+ t.datetime :completed_at
47
+
48
+ t.timestamps
49
+ end
50
+
51
+ create_table :configurations, :force => true do |t|
52
+ t.string :name
53
+ t.string :type, :limit => 50
54
+
55
+ t.timestamps
56
+ end
57
+
58
+ add_index :configurations, [:name, :type], :name => 'index_configurations_on_name_and_type'
59
+
60
+ create_table :countries, :force => true do |t|
61
+ t.string :iso_name, :iso, :iso3, :name
62
+ t.integer :numcode
63
+ end
64
+
65
+ create_table :coupons, :force => true do |t|
66
+ t.string :code, :description
67
+ t.integer :usage_limit
68
+ t.boolean :combine
69
+ t.datetime :expires_at, :starts_at
70
+
71
+ t.timestamps
72
+ end
73
+
74
+ create_table :creditcard_txns, :force => true do |t|
75
+ t.integer :creditcard_payment_id, :txn_type
76
+ t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
77
+ t.string :response_code
78
+ t.text :avs_response, :cvv_response
79
+
80
+ t.timestamps
81
+ end
82
+
83
+ create_table :creditcards, :force => true do |t|
84
+ t.text :number, :verification_value
85
+ t.string :month, :year, :cc_type, :display_number, :first_name,
86
+ :last_name, :start_month, :start_year, :issue_number
87
+ t.references :address
88
+ t.references :checkout
89
+
90
+ t.timestamps
91
+ end
92
+
93
+ create_table :gateway_configurations, :force => true do |t|
94
+ t.references :gateway
95
+
96
+ t.timestamps
97
+ end
98
+
99
+ create_table :gateway_option_values, :force => true do |t|
100
+ t.references :gateway_configuration
101
+ t.references :gateway_option
102
+ t.text :value
103
+
104
+ t.timestamps
105
+ end
106
+
107
+ create_table :gateway_options, :force => true do |t|
108
+ t.string :name
109
+ t.text :description
110
+ t.boolean :textarea, :default => false
111
+ t.references :gateway
112
+
113
+ t.timestamps
114
+ end
115
+
116
+ create_table :gateways, :force => true do |t|
117
+ t.string :clazz, :name
118
+ t.text :description
119
+ t.boolean :active
120
+
121
+ t.timestamps
122
+ end
123
+
124
+ create_table :inventory_units, :force => true do |t|
125
+ t.integer :lock_version, :default => 0
126
+ t.string :state
127
+ t.references :variant
128
+ t.references :order
129
+
130
+ t.timestamps
131
+ end
132
+
133
+ create_table :line_items, :force => true do |t|
134
+ t.references :order
135
+ t.references :variant
136
+ t.integer :quantity, :null => false
137
+ t.decimal :price, :precision => 8, :scale => 2, :null => false
138
+
139
+ t.timestamps
140
+ end
141
+
142
+ add_index :line_items, :order_id, :name => 'index_line_items_on_order_id'
143
+ add_index :line_items, :variant_id, :name => 'index_line_items_on_variant_id'
144
+
145
+ create_table :option_types, :force => true do |t|
146
+ t.string :name, :limit => 100
147
+ t.string :presentation, :limit => 100
148
+
149
+ t.timestamps
150
+ end
151
+
152
+ create_table :option_types_prototypes, :id => false, :force => true do |t|
153
+ t.references :prototype
154
+ t.references :option_type
155
+ end
156
+
157
+ create_table :option_values, :force => true do |t|
158
+ t.integer :position
159
+ t.string :name, :presentation
160
+ t.references :option_type
161
+
162
+ t.timestamps
163
+ end
164
+
165
+ create_table :option_values_variants, :id => false, :force => true do |t|
166
+ t.integer :variant_id
167
+ t.integer :option_value_id
168
+ end
169
+
170
+ add_index :option_values_variants, :variant_id, :name => 'index_option_values_variants_on_variant_id'
171
+
172
+ create_table :orders, :force => true do |t|
173
+ t.string :number, :limit => 15
174
+ t.decimal :item_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
175
+ t.decimal :total, :precision => 8, :scale => 2, :default => 0.0, :null => false
176
+ t.string :state
177
+ t.string :token
178
+ t.decimal :adjustment_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
179
+ t.decimal :credit_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
180
+ t.references :user
181
+
182
+ t.timestamps
183
+ end
184
+
185
+ add_index :orders, :number, :name => 'index_orders_on_number'
186
+
187
+ create_table :payments, :force => true do |t|
188
+ t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
189
+ t.string :type
190
+ t.references :order
191
+ t.references :creditcard
192
+
193
+ t.timestamps
194
+ end
195
+
196
+ create_table :preferences, :force => true do |t|
197
+ t.string :attribute, :null => false, :limit => 100
198
+ t.integer :owner_id, :null => false, :limit => 30
199
+ t.string :owner_type, :null => false, :limit => 50
200
+ t.integer :group_id
201
+ t.string :group_type, :limit => 50
202
+ t.string :value
203
+
204
+ t.timestamps
205
+ end
206
+
207
+ add_index :preferences, [:owner_id, :owner_type, :attribute, :group_id, :group_type], :name => 'index_preferences_on_owner_and_attribute_and_preference', :unique => true
208
+
209
+ create_table :product_option_types, :force => true do |t|
210
+ t.integer :position
211
+ t.references :product
212
+ t.references :option_type
213
+
214
+ t.timestamps
215
+ end
216
+
217
+ create_table :product_properties, :force => true do |t|
218
+ t.string :value
219
+ t.references :product
220
+ t.references :property
221
+
222
+ t.timestamps
223
+ end
224
+
225
+ create_table :products, :force => true do |t|
226
+ t.string :name, :default => '', :null => false
227
+ t.text :description
228
+ t.datetime :available_on, :deleted_at
229
+ t.string :permalink, :meta_description, :meta_keywords
230
+ t.references :tax_category
231
+ t.references :shipping_category
232
+
233
+ t.timestamps
234
+ end
235
+
236
+ add_index :products, :available_on, :name => 'index_products_on_available_on'
237
+ add_index :products, :deleted_at, :name => 'index_products_on_deleted_at'
238
+ add_index :products, :name, :name => 'index_products_on_name'
239
+ add_index :products, :permalink, :name => 'index_products_on_permalink'
240
+
241
+ create_table :products_taxons, :id => false, :force => true do |t|
242
+ t.references :product
243
+ t.references :taxon
244
+ end
245
+
246
+ add_index :products_taxons, :product_id, :name => 'index_products_taxons_on_product_id'
247
+ add_index :products_taxons, :taxon_id, :name => 'index_products_taxons_on_taxon_id'
248
+
249
+ create_table :properties, :force => true do |t|
250
+ t.string :name
251
+ t.string :presentation, :null => false
252
+
253
+ t.timestamps
254
+ end
255
+
256
+ create_table :properties_prototypes, :id => false, :force => true do |t|
257
+ t.references :prototype
258
+ t.references :property
259
+ end
260
+
261
+ create_table :prototypes, :force => true do |t|
262
+ t.string :name
263
+
264
+ t.timestamps
265
+ end
266
+
267
+ create_table :roles, :force => true do |t|
268
+ t.string :name
269
+ end
270
+
271
+ create_table :roles_users, :id => false, :force => true do |t|
272
+ t.references :role
273
+ t.references :user
274
+ end
275
+
276
+ add_index :roles_users, :role_id, :name => 'index_roles_users_on_role_id'
277
+ add_index :roles_users, :user_id, :name => 'index_roles_users_on_user_id'
278
+
279
+ create_table :shipments, :force => true do |t|
280
+ t.string :tracking, :number
281
+ t.decimal :cost, :precision => 8, :scale => 2
282
+ t.datetime :shipped_at
283
+ t.references :order
284
+ t.references :shipping_method
285
+ t.references :address
286
+
287
+ t.timestamps
288
+ end
289
+
290
+ create_table :shipping_categories, :force => true do |t|
291
+ t.string :name
292
+
293
+ t.timestamps
294
+ end
295
+
296
+ create_table :shipping_methods, :force => true do |t|
297
+ t.string :name
298
+ t.references :zone
299
+
300
+ t.timestamps
301
+ end
302
+
303
+ create_table :state_events, :force => true do |t|
304
+ t.string :name, :previous_state
305
+ t.references :order
306
+ t.references :user
307
+
308
+ t.timestamps
309
+ end
310
+
311
+ create_table :states, :force => true do |t|
312
+ t.string :name
313
+ t.string :abbr
314
+ t.references :country
315
+ end
316
+
317
+ create_table :tax_categories, :force => true do |t|
318
+ t.string :name, :description
319
+
320
+ t.timestamps
321
+ end
322
+
323
+ create_table :tax_rates, :force => true do |t|
324
+ t.decimal :amount, :precision => 8, :scale => 4
325
+ t.references :zone
326
+ t.references :tax_category
327
+
328
+ t.timestamps
329
+ end
330
+
331
+ create_table :taxonomies, :force => true do |t|
332
+ t.string :name, :null => false
333
+
334
+ t.timestamps
335
+ end
336
+
337
+ create_table :taxons, :force => true do |t|
338
+ t.integer :parent_id
339
+ t.integer :position, :default => 0
340
+ t.string :name, :null => false
341
+ t.string :permalink
342
+ t.references :taxonomy
343
+
344
+ t.timestamps
345
+ end
346
+
347
+ create_table :users, :force => true do |t|
348
+ t.string :crypted_password, :limit => 128, :default => '', :null => false
349
+ t.string :salt, :limit => 128, :default => '', :null => false
350
+ t.string :email, :remember_token, :remember_token_expires_at,
351
+ :persistence_token, :single_access_token, :perishable_token
352
+ t.integer :login_count, :default => 0, :null => false
353
+ t.integer :failed_login_count, :default => 0, :null => false
354
+ t.datetime :last_request_at, :current_login_at, :last_login_at
355
+ t.string :current_login_ip, :last_login_ip, :login
356
+ t.integer :ship_address_id, :bill_address_id
357
+
358
+ t.timestamps
359
+ end
360
+
361
+ create_table :variants, :force => true do |t|
362
+ t.string :sku, :default => '', :null => false
363
+ t.decimal :price, :precision => 8, :scale => 2, :null => false
364
+ t.decimal :weight, :precision => 8, :scale => 2
365
+ t.decimal :height, :precision => 8, :scale => 2
366
+ t.decimal :width, :precision => 8, :scale => 2
367
+ t.decimal :depth, :precision => 8, :scale => 2
368
+ t.datetime :deleted_at
369
+ t.boolean :is_master, :default => false
370
+ t.references :product
371
+ end
372
+
373
+ add_index :variants, :product_id, :name => 'index_variants_on_product_id'
374
+
375
+ create_table :zone_members, :force => true do |t|
376
+ t.integer :zoneable_id
377
+ t.string :zoneable_type
378
+ t.references :zone
379
+
380
+ t.timestamps
381
+ end
382
+
383
+ create_table :zones, :force => true do |t|
384
+ t.string :name, :description
385
+
386
+ t.timestamps
387
+ end
388
+ end
389
+ end
@@ -0,0 +1,6 @@
1
+ class CreateIndexesForInventoryUnits < ActiveRecord::Migration
2
+ def change
3
+ add_index :inventory_units, :variant_id
4
+ add_index :inventory_units, :order_id
5
+ end
6
+ end
@@ -0,0 +1,49 @@
1
+ class AddCountOnHandToVariantsAndProducts < ActiveRecord::Migration
2
+ def up
3
+ add_column :variants, :count_on_hand, :integer, :default => 0, :null => false
4
+ add_column :products, :count_on_hand, :integer, :default => 0, :null => false
5
+
6
+ # Due to our namespacing changes, this migration (from earlier Spree versions) is broken
7
+ # To fix it, temporarily set table name on each of the models involved
8
+ # And then...
9
+ Spree::Variant.table_name = 'variants'
10
+ Spree::Product.table_name = 'products'
11
+ Spree::InventoryUnit.table_name = 'inventory_units'
12
+
13
+ # In some cases needed to reflect changes in table structure
14
+ Spree::Variant.reset_column_information
15
+ Spree::Product.reset_column_information
16
+
17
+ say_with_time 'Transfering inventory units with status on_hand to variants table...' do
18
+ Spree::Variant.all.each do |v|
19
+ v.update_attribute(:count_on_hand, v.inventory_units.with_state('on_hand').size)
20
+ Spree::InventoryUnit.destroy_all(:variant_id => v.id, :state => 'on_hand')
21
+ end
22
+ end
23
+
24
+ say_with_time 'Updating products count on hand' do
25
+ Spree::Product.all.each do |p|
26
+ product_count_on_hand = p.has_variants? ?
27
+ p.variants.inject(0) { |acc, v| acc + v.count_on_hand } :
28
+ (p.master ? p.master.count_on_hand : 0)
29
+ p.update_attribute(:count_on_hand, product_count_on_hand)
30
+ end
31
+ end
32
+
33
+ # ... Switch things back at the end of the migration
34
+ Spree::Variant.table_name = 'spree_variants'
35
+ Spree::Product.table_name = 'spree_products'
36
+ Spree::InventoryUnit.table_name = 'spree_inventory_units'
37
+ end
38
+
39
+ def down
40
+ Spree::Variant.all.each do |v|
41
+ v.count_on_hand.times do
42
+ Spree::InventoryUnit.create(:variant => variant, :state => 'on_hand')
43
+ end
44
+ end
45
+
46
+ remove_column :variants, :count_on_hand
47
+ remove_column :products, :count_on_hand
48
+ end
49
+ end