erp_commerce 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/db/data_migrations/20130408200643_add_credit_card_biz_txn_acct_types.rb +57 -0
  2. data/lib/erp_commerce/version.rb +1 -1
  3. data/spec/dummy/db/data_migrations/20101011152441_payment_gateway_actions.erp_commerce.rb +28 -0
  4. data/spec/dummy/db/data_migrations/20101014142230_financial_txn_types.erp_txns_and_accts.rb +16 -0
  5. data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
  6. data/spec/dummy/db/data_migrations/20110324010232_product_role_types.erp_products.rb +24 -0
  7. data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
  8. data/spec/dummy/db/data_migrations/20110527160807_add_default_prod_avail_types.erp_products.rb +27 -0
  9. data/spec/dummy/db/data_migrations/20110605231556_create_order_party_roles.erp_orders.rb +24 -0
  10. data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
  11. data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +252 -0
  12. data/spec/dummy/db/data_migrations/20110728201730_create_desktop_app_product_manager.erp_products.rb +26 -0
  13. data/spec/dummy/db/data_migrations/20110728201731_create_desktop_app_order_manager.erp_orders.rb +26 -0
  14. data/spec/dummy/db/data_migrations/20110728201732_create_organizer_app_order_management.erp_orders.rb +15 -0
  15. data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +53 -0
  16. data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
  17. data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +21 -0
  18. data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +32 -0
  19. data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
  20. data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +23 -0
  21. data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +42 -0
  22. data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
  23. data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
  24. data/spec/dummy/db/data_migrations/20120229174343_add_orders_widget.erp_orders.rb +29 -0
  25. data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
  26. data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +19 -0
  27. data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +23 -0
  28. data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
  29. data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
  30. data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
  31. data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +23 -0
  32. data/spec/dummy/db/data_migrations/20130422155150_upgrade_compass_ae_instances_data.erp_base_erp_svcs.rb +19 -0
  33. data/spec/dummy/db/data_migrations/20130422155151_add_guid_to_instances.erp_base_erp_svcs.rb +10 -0
  34. data/spec/dummy/db/data_migrations/20130422155152_create_job_tracker_desktop_application.erp_app.rb +23 -0
  35. data/spec/dummy/db/data_migrations/20130422155153_created_tracked_jobs.erp_app.rb +15 -0
  36. data/spec/dummy/db/data_migrations/20130422155154_add_job_tracker_mobile_app.erp_app.rb +17 -0
  37. data/spec/dummy/db/data_migrations/20130422155155_add_credit_card_biz_txn_acct_types.erp_commerce.rb +58 -0
  38. data/spec/dummy/db/migrate/20130107205819_base_erp_services.erp_base_erp_svcs.rb +461 -0
  39. data/spec/dummy/db/migrate/20130107205820_base_tech_services.erp_tech_svcs.rb +271 -0
  40. data/spec/dummy/db/migrate/20130107205821_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
  41. data/spec/dummy/db/migrate/20130107205822_create_groups.erp_tech_svcs.rb +19 -0
  42. data/spec/dummy/db/migrate/20130107205823_upgrade_security.erp_tech_svcs.rb +54 -0
  43. data/spec/dummy/db/migrate/20130107205824_upgrade_security2.erp_tech_svcs.rb +270 -0
  44. data/spec/dummy/db/migrate/20130107205825_base_app_framework.erp_app.rb +276 -0
  45. data/spec/dummy/db/migrate/20130107205826_base_txns_and_accts.erp_txns_and_accts.rb +364 -0
  46. data/spec/dummy/db/migrate/20130107205827_agreements_services.erp_agreements.rb +160 -0
  47. data/spec/dummy/db/migrate/20130107205828_agreements_services_indexes.erp_agreements.rb +52 -0
  48. data/spec/dummy/db/migrate/20130107205829_base_products.erp_products.rb +234 -0
  49. data/spec/dummy/db/migrate/20130107205830_base_products_indexes.erp_products.rb +59 -0
  50. data/spec/dummy/db/migrate/20130107205831_base_orders.erp_orders.rb +178 -0
  51. data/spec/dummy/db/migrate/20130107205832_erp_commerce_base.erp_commerce.rb +442 -0
  52. data/spec/dummy/db/migrate/20130422155141_add_txn_status.erp_base_erp_svcs.rb +37 -0
  53. data/spec/dummy/db/migrate/20130422155142_upgrade_compass_ae_instances.erp_base_erp_svcs.rb +34 -0
  54. data/spec/dummy/db/migrate/20130422155143_add_uuid_compass_ae_instance.erp_base_erp_svcs.rb +17 -0
  55. data/spec/dummy/db/migrate/20130422155144_add_long_lat_to_address.erp_base_erp_svcs.rb +16 -0
  56. data/spec/dummy/db/migrate/20130422155145_add_queue_to_delayed_jobs.erp_tech_svcs.rb +14 -0
  57. data/spec/dummy/db/migrate/20130422155146_add_job_tracker.erp_app.rb +20 -0
  58. data/spec/dummy/db/migrate/20130422155147_update_mobile_application.erp_app.rb +28 -0
  59. data/spec/dummy/db/migrate/20130422155148_add_biz_txn_acct_type_id_to_biz_txn_acct_root.erp_txns_and_accts.rb +6 -0
  60. data/spec/dummy/db/migrate/20130422155149_add_product_instances_nested_set_indexes.erp_products.rb +10 -0
  61. data/spec/dummy/db/schema.rb +1884 -0
  62. data/spec/dummy/db/spec.sqlite3 +0 -0
  63. data/spec/dummy/log/spec.log +7181 -0
  64. metadata +126 -3
@@ -0,0 +1,178 @@
1
+ # This migration comes from erp_orders (originally 20080805000060)
2
+ class BaseOrders < ActiveRecord::Migration
3
+ def self.up
4
+
5
+ unless table_exists?(:order_txns)
6
+ create_table :order_txns do |t|
7
+ t.column :state_machine, :string
8
+ t.column :description, :string
9
+ t.column :order_txn_type_id, :integer
10
+ # Multi-table inheritance info
11
+ # MTI implemented using Rails' polymorphic associations
12
+ # Contact Information
13
+ t.column :email, :string
14
+ t.column :phone_number, :string
15
+ # Shipping Address
16
+ t.column :ship_to_first_name, :string
17
+ t.column :ship_to_last_name, :string
18
+ t.column :ship_to_address_line_1, :string
19
+ t.column :ship_to_address_line_2, :string
20
+ t.column :bill_to_address_line_1, :string
21
+ t.column :bill_to_address_line_2, :string
22
+ t.column :ship_to_city, :string
23
+ t.column :ship_to_state, :string
24
+ t.column :ship_to_postal_code, :string
25
+ t.column :ship_to_country, :string
26
+ # Private parts
27
+ t.column :customer_ip, :string
28
+ t.column :order_number, :integer
29
+ t.column :status, :string
30
+ t.column :error_message, :string
31
+ t.column :order_txn_record_id, :integer
32
+ t.column :order_txn_record_type, :string
33
+ t.timestamps
34
+ end
35
+
36
+ add_index :order_txns, :order_txn_type_id
37
+ add_index :order_txns, [:order_txn_record_id, :order_txn_record_type], :name => 'order_txn_record_idx'
38
+ end
39
+
40
+ unless table_exists?(:order_txn_types)
41
+ create_table :order_txn_types do |t|
42
+ t.column :parent_id, :integer
43
+ t.column :lft, :integer
44
+ t.column :rgt, :integer
45
+ #custom columns go here
46
+ t.column :description, :string
47
+ t.column :comments, :string
48
+ t.column :internal_identifier, :string
49
+ t.column :external_identifier, :string
50
+ t.column :external_id_source, :string
51
+ t.timestamps
52
+ end
53
+
54
+ add_index :order_txn_types, :parent_id
55
+ end
56
+
57
+
58
+ unless table_exists?(:order_line_items)
59
+ create_table :order_line_items do |t|
60
+ t.column :order_txn_id, :integer
61
+ t.column :order_line_item_type_id, :integer
62
+ t.column :product_id, :integer
63
+ t.column :product_description, :string
64
+ t.column :product_instance_id, :integer
65
+ t.column :product_instance_description, :string
66
+ t.column :product_type_id, :integer
67
+ t.column :product_type_description, :string
68
+ t.column :sold_price, :decimal, :precision => 8, :scale => 2
69
+ t.column :sold_price_uom, :integer
70
+ t.column :sold_amount, :integer
71
+ t.column :sold_amount_uom, :integer
72
+ t.column :product_offer_id, :integer
73
+ t.timestamps
74
+ end
75
+
76
+ add_index :order_line_items, :order_txn_id
77
+ add_index :order_line_items, :order_line_item_type_id
78
+ add_index :order_line_items, :product_id
79
+ add_index :order_line_items, :product_instance_id
80
+ add_index :order_line_items, :product_type_id
81
+ add_index :order_line_items, :product_offer_id
82
+ end
83
+
84
+ unless table_exists?(:order_line_item_types)
85
+ create_table :order_line_item_types do |t|
86
+ t.column :parent_id, :integer
87
+ t.column :lft, :integer
88
+ t.column :rgt, :integer
89
+ #custom columns go here
90
+ t.column :description, :string
91
+ t.column :comments, :string
92
+ t.column :internal_identifier, :string
93
+ t.column :external_identifier, :string
94
+ t.column :external_id_source, :string
95
+ t.timestamps
96
+ end
97
+
98
+ add_index :order_line_item_types, :parent_id
99
+ end
100
+
101
+ unless table_exists?(:order_line_item_pty_roles)
102
+ create_table :order_line_item_pty_roles do |t|
103
+ t.column :description, :string
104
+ t.column :order_line_item_id, :integer
105
+ t.column :party_id, :integer
106
+ t.column :line_item_role_type_id, :integer
107
+ t.column :biz_txn_acct_root_id, :integer #optional for splitting orders across accounts
108
+ t.timestamps
109
+ end
110
+
111
+ add_index :order_line_item_pty_roles, :order_line_item_id
112
+ add_index :order_line_item_pty_roles, :party_id
113
+ add_index :order_line_item_pty_roles, :line_item_role_type_id
114
+ add_index :order_line_item_pty_roles, :biz_txn_acct_root_id
115
+ end
116
+
117
+ unless table_exists?(:line_item_role_types)
118
+ create_table :line_item_role_types do |t|
119
+ t.column :parent_id, :integer
120
+ t.column :lft, :integer
121
+ t.column :rgt, :integer
122
+ #custom columns go here
123
+ t.column :description, :string
124
+ t.column :comments, :string
125
+ t.column :internal_identifier, :string
126
+ t.column :external_identifier, :string
127
+ t.column :external_id_source, :string
128
+ t.timestamps
129
+ end
130
+
131
+ add_index :line_item_role_types, :parent_id
132
+ end
133
+
134
+ unless table_exists?(:charge_lines)
135
+ create_table :charge_lines do |t|
136
+ t.string :sti_type
137
+ t.references :money
138
+ t.string :description #could be expanded to include type information, etc.
139
+ t.string :external_identifier
140
+ t.string :external_id_source
141
+
142
+ #polymorphic
143
+ t.references :charged_item, :polymorphic => true
144
+
145
+ t.timestamps
146
+ end
147
+
148
+ add_index :charge_lines, [:charged_item_id, :charged_item_type], :name => 'charged_item_idx'
149
+ end
150
+
151
+ unless table_exists?(:charge_line_payment_txns)
152
+ create_table :charge_line_payment_txns do |t|
153
+ t.column :charge_line_id, :integer
154
+
155
+ #polymorphic
156
+ t.references :payment_txn, :polymorphic => true
157
+
158
+ t.timestamps
159
+ end
160
+
161
+ add_index :charge_line_payment_txns, [:payment_txn_id, :payment_txn_type], :name => 'payment_txn_idx'
162
+ add_index :charge_line_payment_txns, :charge_line_id
163
+ end
164
+ end
165
+
166
+ def self.down
167
+ [
168
+ :charge_lines, :charge_line_payment_txns, :line_item_role_types, :order_line_item_pty_roles,
169
+ :order_line_item_types, :order_line_items, :order_txn_types,
170
+ :order_txns
171
+ ].each do |tbl|
172
+ if table_exists?(tbl)
173
+ drop_table tbl
174
+ end
175
+ end
176
+ end
177
+
178
+ end
@@ -0,0 +1,442 @@
1
+ # This migration comes from erp_commerce (originally 20100823174238)
2
+ class ErpCommerceBase < ActiveRecord::Migration
3
+ def self.up
4
+ #fees
5
+ unless table_exists?(:fees)
6
+ create_table :fees do |t|
7
+ t.references :fee_record, :polymorphic => true
8
+ t.references :money
9
+ t.references :fee_type
10
+ t.string :description
11
+ t.datetime :start_date
12
+ t.datetime :end_date
13
+ t.string :external_identifier
14
+ t.string :external_id_source
15
+
16
+ t.timestamps
17
+ end
18
+
19
+ add_index :fees, [:fee_record_id, :fee_record_type], :name => 'fee_record_idx'
20
+ add_index :fees, :fee_type_id
21
+ add_index :fees, :money_id
22
+ end
23
+
24
+ unless table_exists?(:fee_types)
25
+ create_table :fee_types do |t|
26
+ t.string :internal_identifier
27
+ t.string :description
28
+ t.string :comments
29
+ t.string :external_identifier
30
+ t.string :external_id_source
31
+
32
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
33
+ t.integer :parent_id
34
+ t.integer :lft
35
+ t.integer :rgt
36
+
37
+ t.timestamps
38
+ end
39
+ end
40
+
41
+ #pricing tables
42
+ unless table_exists?(:price_component_types)
43
+ create_table :price_component_types do |t|
44
+
45
+ t.string :description
46
+ t.string :internal_identifier
47
+ t.string :external_identifier
48
+ t.string :external_id_source
49
+
50
+ t.timestamps
51
+ end
52
+ end
53
+
54
+ unless table_exists?(:pricing_plans)
55
+ create_table :pricing_plans do |t|
56
+
57
+ t.string :description
58
+ t.string :comments
59
+
60
+ t.string :internal_identifier
61
+
62
+ t.string :external_identifier
63
+ t.string :external_id_source
64
+
65
+ t.date :from_date
66
+ t.date :thru_date
67
+
68
+ #this is here as a placeholder for an 'interpreter' or 'rule' pattern
69
+ t.string :matching_rules
70
+ #this is here as a placeholder for an 'interpreter' or 'rule' pattern
71
+ t.string :pricing_calculation
72
+
73
+ #support for simple assignment of a single money amount
74
+ t.boolean :is_simple_amount
75
+ t.integer :currency_id
76
+ t.decimal :money_amount, :precision => 8, :scale => 2
77
+
78
+ t.timestamps
79
+ end
80
+ end
81
+
82
+ unless table_exists?(:pricing_plan_components)
83
+ create_table :pricing_plan_components do |t|
84
+
85
+ t.integer :price_component_type_id
86
+ t.string :description
87
+ t.string :comments
88
+
89
+ t.string :internal_identifier
90
+ t.string :external_identifier
91
+ t.string :external_id_source
92
+
93
+
94
+ #this is here as a placeholder for an 'interpreter' or 'rule' pattern
95
+ t.string :matching_rules
96
+ #this is here as a placeholder for an 'interpreter' or 'rule' pattern
97
+ t.string :pricing_calculation
98
+
99
+ #support for simple assignment of a single money amount
100
+ t.boolean :is_simple_amount
101
+ t.integer :currency_id
102
+ t.decimal :money_amount, :precision => 8, :scale => 2
103
+
104
+ t.timestamps
105
+
106
+ end
107
+ add_index :pricing_plan_components, :price_component_type_id
108
+ end
109
+
110
+ unless table_exists?(:valid_price_plan_components)
111
+ create_table :valid_price_plan_components do |t|
112
+
113
+ t.references :pricing_plan
114
+ t.references :pricing_plan_component
115
+
116
+ t.timestamps
117
+
118
+ end
119
+ add_index :valid_price_plan_components, :pricing_plan_id
120
+ add_index :valid_price_plan_components, :pricing_plan_component_id
121
+ end
122
+
123
+ unless table_exists?(:pricing_plan_assignments)
124
+ create_table :pricing_plan_assignments do |t|
125
+
126
+ t.references :pricing_plan
127
+
128
+ #support a polymorhic interface to the thing we want to price
129
+ t.integer :priceable_item_id
130
+ t.string :priceable_item_type
131
+
132
+ t.integer :priority
133
+
134
+ t.timestamps
135
+
136
+ end
137
+ add_index :pricing_plan_assignments, :pricing_plan_id
138
+ add_index :pricing_plan_assignments, [:priceable_item_id,:priceable_item_type], :name => 'priceable_item_idx'
139
+ end
140
+
141
+ unless table_exists?(:prices)
142
+ create_table :prices do |t|
143
+
144
+ t.string :description
145
+
146
+ #support a polymorhic interface to the thing that HAS BEEN priced
147
+ t.integer :priced_item_id
148
+ t.string :priced_item_type
149
+
150
+ #refer to the pricing plan by which this price was calculated
151
+ t.references :pricing_plan
152
+
153
+ t.references :money
154
+
155
+ t.timestamps
156
+
157
+ end
158
+ add_index :prices, :money_id
159
+ add_index :prices, :pricing_plan_id
160
+ add_index :prices, [:priced_item_id,:priced_item_type], :name => 'priced_item_idx'
161
+ end
162
+
163
+ unless table_exists?(:price_components)
164
+ create_table :price_components do |t|
165
+
166
+ t.string :description
167
+ t.references :pricing_plan_component
168
+ t.references :price
169
+ t.references :money
170
+
171
+ #polymorphic relationship
172
+ t.integer :priced_component_id
173
+ t.string :priced_component_type
174
+
175
+ t.timestamps
176
+
177
+ end
178
+ add_index :price_components, :money_id
179
+ add_index :price_components, :pricing_plan_component_id
180
+ add_index :price_components, :price_id
181
+ add_index :price_components, [:priced_component_id,:priced_component_type], :name => 'priced_component_idx'
182
+ end
183
+
184
+ #payment tables
185
+ unless table_exists?(:payments)
186
+ create_table :payments do |t|
187
+
188
+ t.column :success, :boolean
189
+ t.column :reference_number, :string
190
+ t.column :financial_txn_id, :integer
191
+ t.column :current_state, :string
192
+ t.column :authorization_code, :string
193
+ t.string :external_identifier
194
+
195
+ t.timestamps
196
+ end
197
+
198
+ add_index :payments, :financial_txn_id
199
+ end
200
+
201
+ unless table_exists?(:payment_gateways)
202
+ create_table :payment_gateways do |t|
203
+
204
+ t.column :params, :string
205
+ t.column :payment_gateway_action_id, :integer
206
+ t.column :payment_id, :integer
207
+ t.column :response, :string
208
+
209
+ t.timestamps
210
+ end
211
+ end
212
+
213
+ unless table_exists?(:payment_gateway_actions)
214
+ create_table :payment_gateway_actions do |t|
215
+
216
+ t.column :internal_identifier, :string
217
+ t.column :description, :string
218
+
219
+ t.timestamps
220
+ end
221
+ end
222
+
223
+ add_index :payment_gateway_actions, :internal_identifier
224
+
225
+ #tables
226
+ unless table_exists?(:credit_cards)
227
+ create_table :credit_cards do |t|
228
+
229
+ t.column :crypted_private_card_number, :string
230
+ t.column :expiration_month, :integer
231
+ t.column :expiration_year, :integer
232
+
233
+ t.column :description, :string
234
+ t.column :first_name_on_card, :string
235
+ t.column :last_name_on_card, :string
236
+ t.column :card_type, :string
237
+
238
+ t.column :postal_address_id, :integer
239
+ t.column :credit_card_account_purpose_id, :integer
240
+ t.column :credit_card_token, :string
241
+
242
+ t.timestamps
243
+ end
244
+ end
245
+
246
+ unless table_exists?(:credit_card_accounts)
247
+ create_table :credit_card_accounts do |t|
248
+
249
+ t.timestamps
250
+ end
251
+ end
252
+
253
+ unless table_exists?(:credit_card_account_party_roles)
254
+ create_table :credit_card_account_party_roles do |t|
255
+ t.column :credit_card_account_id, :integer
256
+ t.column :role_type_id, :integer
257
+ t.column :party_id, :integer
258
+ t.column :credit_card_id, :integer
259
+
260
+ t.timestamps
261
+ end
262
+
263
+ add_index :credit_card_account_party_roles, :credit_card_account_id
264
+ add_index :credit_card_account_party_roles, :role_type_id
265
+ add_index :credit_card_account_party_roles, :party_id
266
+ add_index :credit_card_account_party_roles, :credit_card_id
267
+ end
268
+
269
+ unless table_exists?(:credit_card_account_purposes)
270
+ create_table :credit_card_account_purposes do |t|
271
+
272
+ t.column :parent_id, :integer
273
+ t.column :lft, :integer
274
+ t.column :rgt, :integer
275
+
276
+ #custom columns go here
277
+
278
+ t.column :description, :string
279
+ t.column :comments, :string
280
+
281
+ t.column :internal_identifier, :string
282
+ t.column :external_identifier, :string
283
+ t.column :external_id_source, :string
284
+
285
+ t.timestamps
286
+ end
287
+ end
288
+
289
+ unless table_exists?(:accepted_credit_cards)
290
+ create_table :accepted_credit_cards do |t|
291
+
292
+ t.references :organization
293
+ t.string :card_type
294
+
295
+ t.timestamps
296
+ end
297
+ end
298
+
299
+ unless table_exists?(:bank_account_types)
300
+ create_table :bank_account_types do |t|
301
+ t.string :description
302
+ t.string :internal_identifier
303
+
304
+ t.timestamps
305
+ end
306
+ end
307
+
308
+ unless table_exists?(:bank_accounts)
309
+ create_table :bank_accounts do |t|
310
+ t.string :routing_number
311
+ t.string :crypted_private_account_number
312
+ t.string :name_on_account
313
+ t.references :bank_account_type
314
+
315
+ t.timestamps
316
+ end
317
+
318
+ add_index :bank_accounts, :bank_account_type_id, :name => 'bank_accounts_account_type_idx'
319
+ end
320
+ #end tables
321
+
322
+ #columns
323
+ unless columns(:order_txns).collect {|c| c.name}.include?('payment_gateway_txn_id')
324
+ add_column :order_txns, :payment_gateway_txn_id, :string
325
+ end
326
+
327
+ unless columns(:order_txns).collect {|c| c.name}.include?('credit_card_id')
328
+ add_column :order_txns, :credit_card_id, :integer
329
+ end
330
+
331
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_first_name')
332
+ add_column :order_txns, :bill_to_first_name, :string
333
+ end
334
+
335
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_last_name')
336
+ add_column :order_txns, :bill_to_last_name, :string
337
+ end
338
+
339
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_address_line_1')
340
+ add_column :order_txns, :bill_to_address_line_1, :string
341
+ end
342
+
343
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_address_line_2')
344
+ add_column :order_txns, :bill_to_address_line_2, :string
345
+ end
346
+
347
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_city')
348
+ add_column :order_txns, :bill_to_city, :string
349
+ end
350
+
351
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_state')
352
+ add_column :order_txns, :bill_to_state, :string
353
+ end
354
+
355
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_postal_code')
356
+ add_column :order_txns, :bill_to_postal_code, :string
357
+ end
358
+
359
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_country')
360
+ add_column :order_txns, :bill_to_country, :string
361
+ end
362
+
363
+ unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_country_name')
364
+ rename_column :order_txns, :bill_to_country, :bill_to_country_name
365
+ rename_column :order_txns, :ship_to_country, :ship_to_country_name
366
+ add_column :order_txns, :bill_to_country, :string
367
+ add_column :order_txns, :ship_to_country, :string
368
+ end
369
+ #end
370
+ end
371
+
372
+ def self.down
373
+
374
+ if columns(:order_txns).collect {|c| c.name}.include?('payment_gateway_txn_id')
375
+ remove_column :order_txns, :payment_gateway_txn_id
376
+ end
377
+
378
+ if columns(:order_txns).collect {|c| c.name}.include?('credit_card_id')
379
+ remove_column :order_txns, :credit_card_id, :integer
380
+ end
381
+
382
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_first_name')
383
+ remove_column :order_txns, :bill_to_first_name, :string
384
+ end
385
+
386
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_last_name')
387
+ remove_column :order_txns, :bill_to_last_name, :string
388
+ end
389
+
390
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_address')
391
+ remove_column :order_txns, :bill_to_address, :string
392
+ end
393
+
394
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_city')
395
+ remove_column :order_txns, :bill_to_city, :string
396
+ end
397
+
398
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_state')
399
+ remove_column :order_txns, :bill_to_state, :string
400
+ end
401
+
402
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_postal_code')
403
+ remove_column :order_txns, :bill_to_postal_code, :string
404
+ end
405
+
406
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_country')
407
+ remove_column :order_txns, :bill_to_country, :string
408
+ end
409
+
410
+ if columns(:order_txns).collect {|c| c.name}.include?('bill_to_country_name')
411
+ remove_column :order_txns, :bill_to_country, :bill_to_country_name
412
+ remove_column :order_txns, :ship_to_country, :ship_to_country_name
413
+ end
414
+
415
+ #tables
416
+ drop_tables = [
417
+ :bank_account_types,
418
+ :bank_accounts,
419
+ :credit_cards,
420
+ :credit_card_accounts,
421
+ :credit_card_account_party_roles,
422
+ :credit_card_account_purposes,
423
+ :payments,
424
+ :payment_gateways,
425
+ :payment_gateway_actions,
426
+ :pricing_plans,
427
+ :pricing_plan_components,
428
+ :valid_price_plan_components,
429
+ :pricing_plan_assignments,
430
+ :prices,
431
+ :price_components,
432
+ :price_component_types,
433
+ :fees,:fee_types
434
+ ]
435
+ drop_tables.each do |table|
436
+ if table_exists?(table)
437
+ drop_table table
438
+ end
439
+ end
440
+
441
+ end
442
+ end