erp_products 3.0.5 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/app/models/prod_availability_status_type.rb +2 -0
  2. data/app/models/prod_instance_reln.rb +1 -0
  3. data/app/models/prod_instance_reln_type.rb +2 -0
  4. data/app/models/prod_instance_role_type.rb +2 -0
  5. data/app/models/prod_type_reln.rb +1 -0
  6. data/app/models/prod_type_reln_type.rb +2 -0
  7. data/app/models/prod_type_role_type.rb +2 -0
  8. data/app/models/product_instance.rb +2 -0
  9. data/app/models/product_offer.rb +1 -0
  10. data/app/models/product_type.rb +2 -0
  11. data/app/models/simple_product_offer.rb +2 -0
  12. data/db/migrate/20080805000040_base_products.rb +1 -0
  13. data/lib/erp_products.rb +2 -0
  14. data/lib/erp_products/version.rb +2 -2
  15. data/spec/dummy/config/application.rb +6 -0
  16. data/spec/dummy/config/environments/spec.rb +3 -0
  17. data/spec/dummy/db/data_migrations/20101011152441_payment_gateway_actions.erp_commerce.rb +28 -0
  18. data/spec/dummy/db/data_migrations/20101014142230_financial_txn_types.erp_txns_and_accts.rb +16 -0
  19. data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
  20. data/spec/dummy/db/data_migrations/20110324010232_product_role_types.erp_products.rb +24 -0
  21. data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
  22. data/spec/dummy/db/data_migrations/20110527160807_add_default_prod_avail_types.erp_products.rb +27 -0
  23. data/spec/dummy/db/data_migrations/20110605231556_create_order_party_roles.erp_orders.rb +24 -0
  24. data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
  25. data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +252 -0
  26. data/spec/dummy/db/data_migrations/20110728201730_create_desktop_app_product_manager.erp_products.rb +26 -0
  27. data/spec/dummy/db/data_migrations/20110728201731_create_desktop_app_order_manager.erp_orders.rb +26 -0
  28. data/spec/dummy/db/data_migrations/20110728201732_create_organizer_app_order_management.erp_orders.rb +15 -0
  29. data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +53 -0
  30. data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
  31. data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +21 -0
  32. data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +32 -0
  33. data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
  34. data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +23 -0
  35. data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +42 -0
  36. data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
  37. data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
  38. data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
  39. data/spec/dummy/db/data_migrations/20120229174343_add_orders_widget.erp_orders.rb +29 -0
  40. data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
  41. data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +19 -0
  42. data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +23 -0
  43. data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
  44. data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
  45. data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
  46. data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +23 -0
  47. data/spec/dummy/db/migrate/20130107214711_base_erp_services.erp_base_erp_svcs.rb +461 -0
  48. data/spec/dummy/db/migrate/20130107214712_base_products.erp_products.rb +234 -0
  49. data/spec/dummy/db/migrate/20130107214713_base_products_indexes.erp_products.rb +59 -0
  50. data/spec/dummy/db/migrate/20130107214714_base_tech_services.erp_tech_svcs.rb +271 -0
  51. data/spec/dummy/db/migrate/20130107214715_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
  52. data/spec/dummy/db/migrate/20130107214716_create_groups.erp_tech_svcs.rb +19 -0
  53. data/spec/dummy/db/migrate/20130107214717_upgrade_security.erp_tech_svcs.rb +54 -0
  54. data/spec/dummy/db/migrate/20130107214718_upgrade_security2.erp_tech_svcs.rb +270 -0
  55. data/spec/dummy/db/migrate/20130107214719_base_orders.erp_orders.rb +178 -0
  56. data/spec/dummy/db/migrate/20130107214720_base_txns_and_accts.erp_txns_and_accts.rb +364 -0
  57. data/spec/dummy/db/migrate/20130107214721_agreements_services.erp_agreements.rb +160 -0
  58. data/spec/dummy/db/migrate/20130107214722_agreements_services_indexes.erp_agreements.rb +52 -0
  59. data/spec/dummy/db/migrate/20130107214723_base_app_framework.erp_app.rb +276 -0
  60. data/spec/dummy/db/migrate/20130107214724_erp_commerce_base.erp_commerce.rb +442 -0
  61. data/spec/dummy/db/schema.rb +1821 -0
  62. data/spec/dummy/db/spec.sqlite3 +0 -0
  63. data/spec/dummy/log/spec.log +12388 -0
  64. data/spec/spec_helper.rb +11 -3
  65. metadata +119 -10
  66. data/db/migrate/20120612195842_add_internal_identifier_to_product_type.rb +0 -9
@@ -0,0 +1,52 @@
1
+ # This migration comes from erp_agreements (originally 20080805000071)
2
+ class AgreementsServicesIndexes < ActiveRecord::Migration
3
+ def self.up
4
+ add_index :agreements, :agreement_type_id
5
+ add_index :agreements, :product_id
6
+
7
+ add_index :agreement_types, :parent_id
8
+
9
+ add_index :agreement_items, :agreement_id
10
+ add_index :agreement_items, :agreement_item_type_id
11
+
12
+ add_index :agreement_item_types, :parent_id
13
+
14
+ add_index :agreement_party_roles, :agreement_id
15
+ add_index :agreement_party_roles, :party_id
16
+ add_index :agreement_party_roles, :role_type_id
17
+
18
+ add_index :agreement_relationships, :agreement_reln_type_id
19
+ add_index :agreement_relationships, :status_type_id
20
+
21
+ add_index :agreement_reln_types, :parent_id
22
+ add_index :agreement_reln_types, :valid_from_role_type_id
23
+ add_index :agreement_reln_types, :valid_to_role_type_id
24
+
25
+ add_index :agreement_role_types, :parent_id
26
+ end
27
+
28
+ def self.down
29
+ remove_index :agreements, :agreement_type_id
30
+ remove_index :agreements, :product_id
31
+
32
+ remove_index :agreement_types, :parent_id
33
+
34
+ remove_index :agreement_items, :agreement_id
35
+ remove_index :agreement_items, :agreement_item_type_id
36
+
37
+ remove_index :agreement_item_types, :parent_id
38
+
39
+ remove_index :agreement_party_roles, :agreement_id
40
+ remove_index :agreement_party_roles, :party_id
41
+ remove_index :agreement_party_roles, :role_type_id
42
+
43
+ remove_index :agreement_relationships, :agreement_reln_type_id
44
+ remove_index :agreement_relationships, :status_type_id
45
+
46
+ remove_index :agreement_reln_types, :parent_id
47
+ remove_index :agreement_reln_types, :valid_from_role_type_id
48
+ remove_index :agreement_reln_types, :valid_to_role_type_id
49
+
50
+ remove_index :agreement_role_types, :parent_id
51
+ end
52
+ end
@@ -0,0 +1,276 @@
1
+ # This migration comes from erp_app (originally 20080805000096)
2
+ class BaseAppFramework < ActiveRecord::Migration
3
+ def self.up
4
+
5
+ unless table_exists?(:preferences)
6
+ create_table :preferences do |t|
7
+ t.references :preference_option
8
+ t.references :preference_type
9
+
10
+ t.timestamps
11
+ end
12
+ add_index :preferences, :preference_option_id
13
+ add_index :preferences, :preference_type_id
14
+ end
15
+
16
+ unless table_exists?(:preference_types)
17
+ create_table :preference_types do |t|
18
+ t.string :description
19
+ t.string :internal_identifier
20
+ t.integer :default_pref_option_id
21
+
22
+ t.timestamps
23
+ end
24
+
25
+ add_index :preference_types, :default_pref_option_id
26
+ end
27
+
28
+ unless table_exists?(:preference_options)
29
+ create_table :preference_options do |t|
30
+ t.string :description
31
+ t.string :internal_identifier
32
+ t.string :value
33
+
34
+ t.timestamps
35
+ end
36
+ end
37
+
38
+ unless table_exists?(:preference_options_preference_types)
39
+ create_table :preference_options_preference_types, {:id => false} do |t|
40
+ t.references :preference_type
41
+ t.references :preference_option
42
+ end
43
+
44
+ add_index :preference_options_preference_types, :preference_type_id, :name => 'pref_opt_pref_type_pref_type_id_idx'
45
+ add_index :preference_options_preference_types, :preference_option_id, :name => 'pref_opt_pref_type_pref_opt_id_idx'
46
+ end
47
+
48
+ unless table_exists?(:valid_preference_types)
49
+ create_table :valid_preference_types do |t|
50
+ t.references :preference_type
51
+ t.references :preferenced_record, :polymorphic => true
52
+ end
53
+ end
54
+
55
+ unless table_exists?(:user_preferences)
56
+ create_table :user_preferences do |t|
57
+ t.references :user
58
+ t.references :preference
59
+
60
+ t.references :preferenced_record, :polymorphic => true
61
+
62
+ t.timestamps
63
+ end
64
+ add_index :user_preferences, :user_id
65
+ add_index :user_preferences, :preference_id
66
+ add_index :user_preferences, :preferenced_record_id
67
+ add_index :user_preferences, :preferenced_record_type
68
+ end
69
+
70
+ unless table_exists?(:app_containers)
71
+ create_table :app_containers do |t|
72
+ t.references :user
73
+ t.string :description
74
+ t.string :internal_identifier
75
+ t.string :type
76
+
77
+ t.timestamps
78
+ end
79
+ add_index :app_containers, :user_id
80
+ add_index :app_containers, :type
81
+ end
82
+
83
+ unless table_exists?(:applications)
84
+ create_table :applications do |t|
85
+ t.column :description, :string
86
+ t.column :icon, :string
87
+ t.column :internal_identifier, :string
88
+ t.column :javascript_class_name, :string
89
+ t.column :shortcut_id, :string
90
+ t.column :base_url, :string
91
+ t.column :type, :string
92
+
93
+ t.timestamps
94
+ end
95
+ end
96
+
97
+ unless table_exists?(:app_containers_applications)
98
+ create_table :app_containers_applications, {:id => false} do |t|
99
+ t.column :app_container_id, :integer
100
+ t.column :application_id, :integer
101
+ end
102
+
103
+ add_index :app_containers_applications, :application_id
104
+ add_index :app_containers_applications, :app_container_id
105
+ end
106
+
107
+ unless table_exists?(:widgets)
108
+ create_table :widgets do |t|
109
+ t.column :description, :string
110
+ t.column :internal_identifier, :string
111
+ t.column :icon, :string
112
+ t.column :xtype, :string
113
+
114
+ t.timestamps
115
+ end
116
+ end
117
+
118
+ unless table_exists?(:applications_widgets)
119
+ create_table :applications_widgets, {:id => false} do |t|
120
+ t.column :application_id, :integer
121
+ t.column :widget_id, :integer
122
+ end
123
+ add_index :applications_widgets, :application_id
124
+ add_index :applications_widgets, :widget_id
125
+ end
126
+
127
+ unless table_exists?(:tree_menu_node_defs)
128
+ create_table :tree_menu_node_defs do |t|
129
+ t.string :node_type
130
+ t.integer :parent_id
131
+ t.integer :lft
132
+ t.integer :rgt
133
+ t.string :menu_short_name
134
+ t.string :menu_description
135
+ t.string :text
136
+ t.string :icon_url
137
+ t.string :target_url
138
+ t.string :resource_class
139
+ t.timestamps
140
+ end
141
+ add_index :tree_menu_node_defs, :parent_id
142
+ end
143
+
144
+ unless table_exists? :configurations
145
+ create_table :configurations do |t|
146
+ #custom columns go here
147
+ t.string :description
148
+ t.string :internal_identifier
149
+ t.boolean :active
150
+ t.boolean :is_template, :default => false
151
+
152
+ t.timestamps
153
+ end
154
+
155
+ add_index :configurations, :is_template
156
+ end
157
+
158
+ unless table_exists? :valid_configurations
159
+ create_table :valid_configurations do |t|
160
+ #foreign keys
161
+ t.references :configured_item, :polymorphic => true
162
+ t.references :configuration
163
+
164
+ t.timestamps
165
+ end
166
+
167
+ add_index :valid_configurations, [:configured_item_id, :configured_item_type], :name => 'configured_item_poly_idx'
168
+ add_index :valid_configurations, :configuration_id
169
+ end
170
+
171
+ unless table_exists? :configuration_items
172
+ create_table :configuration_items do |t|
173
+ #foreign keys
174
+ t.references :configuration
175
+ t.references :configuration_item_type
176
+ t.references :configuration_option
177
+
178
+ t.timestamps
179
+ end
180
+
181
+ add_index :configuration_items, :configuration_id
182
+ add_index :configuration_items, :configuration_item_type_id
183
+ add_index :configuration_items, :configuration_option_id
184
+ end
185
+
186
+ unless table_exists? :configuration_item_types
187
+ create_table :configuration_item_types do |t|
188
+ #awesome nested set columns
189
+ t.integer :parent_id
190
+ t.integer :lft
191
+ t.integer :rgt
192
+
193
+ #custom columns go here
194
+ t.string :description
195
+ t.string :internal_identifier
196
+ t.boolean :allow_user_defined_options, :default => false
197
+ t.boolean :is_multi_optional, :default => false
198
+
199
+ t.timestamps
200
+ end
201
+ end
202
+
203
+ unless table_exists?(:configuration_item_types_configurations)
204
+ create_table :configuration_item_types_configurations, {:id => false} do |t|
205
+ t.references :configuration_item_type
206
+ t.references :configuration
207
+ end
208
+
209
+ add_index :configuration_item_types_configurations, :configuration_item_type_id, :name => 'conf_conf_type_id_item_idx'
210
+ add_index :configuration_item_types_configurations, :configuration_id, :name => 'conf_id_idx'
211
+ add_index :configuration_item_types_configurations, [:configuration_item_type_id, :configuration_id], :unique => true, :name => 'conf_config_type_uniq_idx'
212
+ end
213
+
214
+ unless table_exists? :configuration_options
215
+ create_table :configuration_options do |t|
216
+ #custom columns go here
217
+ t.string :description
218
+ t.string :internal_identifier
219
+ t.string :value
220
+ t.text :comment
221
+ t.boolean :user_defined, :default => false
222
+
223
+ t.timestamps
224
+ end
225
+
226
+ add_index :configuration_options, :value
227
+ add_index :configuration_options, :internal_identifier
228
+ add_index :configuration_options, :user_defined
229
+ end
230
+
231
+ unless table_exists?(:configuration_item_types_configuration_options)
232
+ create_table :configuration_item_types_configuration_options do |t|
233
+ t.references :configuration_item_type
234
+ t.references :configuration_option
235
+ t.boolean :is_default, :default => false
236
+
237
+ t.timestamps
238
+ end
239
+
240
+ add_index :configuration_item_types_configuration_options, :configuration_item_type_id, :name => 'conf_item_type_conf_opt_id_item_idx'
241
+ add_index :configuration_item_types_configuration_options, :configuration_option_id, :name => 'conf_item_type_conf_opt_id_opt_idx'
242
+ end
243
+
244
+ unless table_exists?(:configuration_items_configuration_options)
245
+ create_table :configuration_items_configuration_options, {:id => false} do |t|
246
+ t.references :configuration_item
247
+ t.references :configuration_option
248
+ end
249
+
250
+ add_index :configuration_items_configuration_options, :configuration_item_id, :name => 'conf_item_conf_opt_id_item_idx'
251
+ add_index :configuration_items_configuration_options, :configuration_option_id, :name => 'conf_item_conf_opt_id_opt_idx'
252
+ end
253
+
254
+ end
255
+
256
+ def self.down
257
+ [
258
+ :preferences, :preference_types,
259
+ :preference_options, :preference_options_preference_types,
260
+ :valid_preference_types, :user_preferences,
261
+ :app_containers, :app_containers_applications,
262
+ :applications_widgets, :widgets, :tree_menu_node_defs,
263
+ :applications, :applications_desktops,
264
+ :configurations, :configuration_items,
265
+ :configuration_item_types, :configuration_options,
266
+ :configuration_item_types_configuration_options,
267
+ :configuration_items_configuration_options, :configured_items,
268
+ :configuration_item_types_configurations
269
+ ].each do |tbl|
270
+ if table_exists?(tbl)
271
+ drop_table(tbl)
272
+ end
273
+ end
274
+ end
275
+
276
+ 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