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.
- data/app/models/prod_availability_status_type.rb +2 -0
- data/app/models/prod_instance_reln.rb +1 -0
- data/app/models/prod_instance_reln_type.rb +2 -0
- data/app/models/prod_instance_role_type.rb +2 -0
- data/app/models/prod_type_reln.rb +1 -0
- data/app/models/prod_type_reln_type.rb +2 -0
- data/app/models/prod_type_role_type.rb +2 -0
- data/app/models/product_instance.rb +2 -0
- data/app/models/product_offer.rb +1 -0
- data/app/models/product_type.rb +2 -0
- data/app/models/simple_product_offer.rb +2 -0
- data/db/migrate/20080805000040_base_products.rb +1 -0
- data/lib/erp_products.rb +2 -0
- data/lib/erp_products/version.rb +2 -2
- data/spec/dummy/config/application.rb +6 -0
- data/spec/dummy/config/environments/spec.rb +3 -0
- data/spec/dummy/db/data_migrations/20101011152441_payment_gateway_actions.erp_commerce.rb +28 -0
- data/spec/dummy/db/data_migrations/20101014142230_financial_txn_types.erp_txns_and_accts.rb +16 -0
- data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
- data/spec/dummy/db/data_migrations/20110324010232_product_role_types.erp_products.rb +24 -0
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20110527160807_add_default_prod_avail_types.erp_products.rb +27 -0
- data/spec/dummy/db/data_migrations/20110605231556_create_order_party_roles.erp_orders.rb +24 -0
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
- data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +252 -0
- data/spec/dummy/db/data_migrations/20110728201730_create_desktop_app_product_manager.erp_products.rb +26 -0
- data/spec/dummy/db/data_migrations/20110728201731_create_desktop_app_order_manager.erp_orders.rb +26 -0
- data/spec/dummy/db/data_migrations/20110728201732_create_organizer_app_order_management.erp_orders.rb +15 -0
- data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +53 -0
- data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
- data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +21 -0
- data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +32 -0
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +23 -0
- data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +42 -0
- data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
- data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
- data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
- data/spec/dummy/db/data_migrations/20120229174343_add_orders_widget.erp_orders.rb +29 -0
- data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
- data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +19 -0
- data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +23 -0
- data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
- data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
- data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
- data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +23 -0
- data/spec/dummy/db/migrate/20130107214711_base_erp_services.erp_base_erp_svcs.rb +461 -0
- data/spec/dummy/db/migrate/20130107214712_base_products.erp_products.rb +234 -0
- data/spec/dummy/db/migrate/20130107214713_base_products_indexes.erp_products.rb +59 -0
- data/spec/dummy/db/migrate/20130107214714_base_tech_services.erp_tech_svcs.rb +271 -0
- data/spec/dummy/db/migrate/20130107214715_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
- data/spec/dummy/db/migrate/20130107214716_create_groups.erp_tech_svcs.rb +19 -0
- data/spec/dummy/db/migrate/20130107214717_upgrade_security.erp_tech_svcs.rb +54 -0
- data/spec/dummy/db/migrate/20130107214718_upgrade_security2.erp_tech_svcs.rb +270 -0
- data/spec/dummy/db/migrate/20130107214719_base_orders.erp_orders.rb +178 -0
- data/spec/dummy/db/migrate/20130107214720_base_txns_and_accts.erp_txns_and_accts.rb +364 -0
- data/spec/dummy/db/migrate/20130107214721_agreements_services.erp_agreements.rb +160 -0
- data/spec/dummy/db/migrate/20130107214722_agreements_services_indexes.erp_agreements.rb +52 -0
- data/spec/dummy/db/migrate/20130107214723_base_app_framework.erp_app.rb +276 -0
- data/spec/dummy/db/migrate/20130107214724_erp_commerce_base.erp_commerce.rb +442 -0
- data/spec/dummy/db/schema.rb +1821 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +12388 -0
- data/spec/spec_helper.rb +11 -3
- metadata +119 -10
- data/db/migrate/20120612195842_add_internal_identifier_to_product_type.rb +0 -9
@@ -0,0 +1,234 @@
|
|
1
|
+
# This migration comes from erp_products (originally 20080805000040)
|
2
|
+
class BaseProducts < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
|
5
|
+
unless table_exists?(:product_types)
|
6
|
+
create_table :product_types do |t|
|
7
|
+
#these columns are required to support the behavior of the plugin 'better_nested_set'
|
8
|
+
#ALL products have the ability to act as packages in a nested set-type structure
|
9
|
+
#
|
10
|
+
#The package behavior is treated differently from other product_relationship behavior
|
11
|
+
#which is implemented using a standard relationship structure.
|
12
|
+
#
|
13
|
+
#This is to allow quick construction of highly nested product types.
|
14
|
+
t.column :parent_id, :integer
|
15
|
+
t.column :lft, :integer
|
16
|
+
t.column :rgt, :integer
|
17
|
+
|
18
|
+
#custom columns go here
|
19
|
+
t.column :description, :string
|
20
|
+
t.column :product_type_record_id, :integer
|
21
|
+
t.column :product_type_record_type, :string
|
22
|
+
t.column :external_identifier, :string
|
23
|
+
t.column :internal_identifier, :string
|
24
|
+
t.column :external_id_source, :string
|
25
|
+
t.column :default_image_url, :string
|
26
|
+
t.column :list_view_image_id, :integer
|
27
|
+
t.timestamps
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
unless table_exists?(:product_instances)
|
32
|
+
create_table :product_instances do |t|
|
33
|
+
#these columns are required to support the behavior of the plugin 'better_nested_set'
|
34
|
+
#ALL products have the ability to act as packages in a nested set-type structure
|
35
|
+
#
|
36
|
+
#The package behavior is treated differently from other product_relationship behavior
|
37
|
+
#which is implemented using a standard relationship structure.
|
38
|
+
#
|
39
|
+
#This is to allow quick construction of highly nested product types.
|
40
|
+
t.column :parent_id, :integer
|
41
|
+
t.column :lft, :integer
|
42
|
+
t.column :rgt, :integer
|
43
|
+
|
44
|
+
#custom columns go here
|
45
|
+
t.column :description, :string
|
46
|
+
t.column :product_instance_record_id, :integer
|
47
|
+
t.column :product_instance_record_type, :string
|
48
|
+
t.column :external_identifier, :string
|
49
|
+
t.column :external_id_source, :string
|
50
|
+
t.column :product_type_id, :integer
|
51
|
+
t.column :type, :string
|
52
|
+
|
53
|
+
t.references :prod_availability_status_type
|
54
|
+
|
55
|
+
t.timestamps
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
unless table_exists?(:product_offers)
|
60
|
+
create_table :product_offers do |t|
|
61
|
+
t.column :description, :string
|
62
|
+
t.column :product_offer_record_id, :integer
|
63
|
+
t.column :product_offer_record_type, :string
|
64
|
+
t.column :external_identifier, :string
|
65
|
+
t.column :external_id_source, :string
|
66
|
+
t.timestamps
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
unless table_exists?(:simple_product_offers)
|
71
|
+
create_table :simple_product_offers do |t|
|
72
|
+
t.column :description, :string
|
73
|
+
t.column :product_id, :integer
|
74
|
+
t.column :base_price, :decimal, :precision => 8, :scale => 2
|
75
|
+
t.column :uom, :integer
|
76
|
+
t.timestamps
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
unless table_exists?(:prod_instance_reln_types)
|
81
|
+
create_table :prod_instance_reln_types do |t|
|
82
|
+
t.column :parent_id, :integer
|
83
|
+
t.column :lft, :integer
|
84
|
+
t.column :rgt, :integer
|
85
|
+
|
86
|
+
#custom columns go here
|
87
|
+
t.column :description, :string
|
88
|
+
t.column :comments, :string
|
89
|
+
t.column :internal_identifier, :string
|
90
|
+
t.column :external_identifier, :string
|
91
|
+
t.column :external_id_source, :string
|
92
|
+
t.timestamps
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
unless table_exists?(:prod_instance_role_types)
|
97
|
+
create_table :prod_instance_role_types do |t|
|
98
|
+
t.column :parent_id, :integer
|
99
|
+
t.column :lft, :integer
|
100
|
+
t.column :rgt, :integer
|
101
|
+
#custom columns go here
|
102
|
+
t.column :description, :string
|
103
|
+
t.column :comments, :string
|
104
|
+
t.column :internal_identifier, :string
|
105
|
+
t.column :external_identifier, :string
|
106
|
+
t.column :external_id_source, :string
|
107
|
+
t.timestamps
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
unless table_exists?(:prod_instance_relns)
|
112
|
+
create_table :prod_instance_relns do |t|
|
113
|
+
t.column :prod_instance_reln_type_id, :integer
|
114
|
+
t.column :description, :string
|
115
|
+
t.column :prod_instance_id_from, :integer
|
116
|
+
t.column :prod_instance_id_to, :integer
|
117
|
+
t.column :role_type_id_from, :integer
|
118
|
+
t.column :role_type_id_to, :integer
|
119
|
+
t.column :status_type_id, :integer
|
120
|
+
t.column :from_date, :date
|
121
|
+
t.column :thru_date, :date
|
122
|
+
t.timestamps
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
unless table_exists?(:prod_type_reln_types)
|
127
|
+
create_table :prod_type_reln_types do |t|
|
128
|
+
t.column :parent_id, :integer
|
129
|
+
t.column :lft, :integer
|
130
|
+
t.column :rgt, :integer
|
131
|
+
#custom columns go here
|
132
|
+
t.column :description, :string
|
133
|
+
t.column :comments, :string
|
134
|
+
t.column :internal_identifier, :string
|
135
|
+
t.column :external_identifier, :string
|
136
|
+
t.column :external_id_source, :string
|
137
|
+
t.timestamps
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
unless table_exists?(:prod_type_role_types)
|
142
|
+
create_table :prod_type_role_types do |t|
|
143
|
+
t.column :parent_id, :integer
|
144
|
+
t.column :lft, :integer
|
145
|
+
t.column :rgt, :integer
|
146
|
+
#custom columns go here
|
147
|
+
t.column :description, :string
|
148
|
+
t.column :comments, :string
|
149
|
+
t.column :internal_identifier, :string
|
150
|
+
t.column :external_identifier, :string
|
151
|
+
t.column :external_id_source, :string
|
152
|
+
t.timestamps
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
unless table_exists?(:prod_type_relns)
|
157
|
+
create_table :prod_type_relns do |t|
|
158
|
+
t.column :prod_type_reln_type_id, :integer
|
159
|
+
t.column :description, :string
|
160
|
+
t.column :prod_type_id_from, :integer
|
161
|
+
t.column :prod_type_id_to, :integer
|
162
|
+
t.column :role_type_id_from, :integer
|
163
|
+
t.column :role_type_id_to, :integer
|
164
|
+
t.column :status_type_id, :integer
|
165
|
+
t.column :from_date, :date
|
166
|
+
t.column :thru_date, :date
|
167
|
+
t.timestamps
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
unless table_exists?(:product_instance_status_types)
|
172
|
+
create_table :product_instance_status_types do |t|
|
173
|
+
#better nested set colummns
|
174
|
+
t.column :parent_id, :integer
|
175
|
+
t.column :lft, :integer
|
176
|
+
t.column :rgt, :integer
|
177
|
+
|
178
|
+
t.column :description, :string
|
179
|
+
t.column :internal_identifier, :string
|
180
|
+
t.column :external_identifier, :string
|
181
|
+
t.column :external_id_source, :string
|
182
|
+
|
183
|
+
t.timestamps
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
unless table_exists?(:prod_availability_status_types)
|
188
|
+
create_table :prod_availability_status_types do |t|
|
189
|
+
#better nested set colummns
|
190
|
+
t.column :parent_id, :integer
|
191
|
+
t.column :lft, :integer
|
192
|
+
t.column :rgt, :integer
|
193
|
+
|
194
|
+
t.column :description, :string
|
195
|
+
t.column :internal_identifier, :string
|
196
|
+
t.column :external_identifier, :string
|
197
|
+
t.column :external_id_source, :string
|
198
|
+
|
199
|
+
t.timestamps
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
unless table_exists?(:prod_availability_status_types)
|
204
|
+
create_table :prod_availability_status_types do |t|
|
205
|
+
#better nested set colummns
|
206
|
+
t.column :parent_id, :integer
|
207
|
+
t.column :lft, :integer
|
208
|
+
t.column :rgt, :integer
|
209
|
+
|
210
|
+
t.column :description, :string
|
211
|
+
t.column :internal_identifier, :string
|
212
|
+
t.column :external_identifier, :string
|
213
|
+
t.column :external_id_source, :string
|
214
|
+
|
215
|
+
t.timestamps
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
def self.down
|
223
|
+
[
|
224
|
+
:prod_type_relns, :prod_type_role_types, :prod_type_reln_types,
|
225
|
+
:prod_instance_relns, :prod_instance_role_types, :prod_instance_reln_types,
|
226
|
+
:simple_product_offers, :product_offers, :product_instances,
|
227
|
+
:product_types,:prod_availability_status_types
|
228
|
+
].each do |tbl|
|
229
|
+
if table_exists?(tbl)
|
230
|
+
drop_table tbl
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# This migration comes from erp_products (originally 20080805000041)
|
2
|
+
class BaseProductsIndexes < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
add_index :product_types, :parent_id
|
5
|
+
add_index :product_types, [:product_type_record_id, :product_type_record_type],
|
6
|
+
:name => "bpi_1"
|
7
|
+
|
8
|
+
add_index :product_instances, :parent_id
|
9
|
+
add_index :product_instances, [:product_instance_record_id, :product_instance_record_type],
|
10
|
+
:name => "bpi_2"
|
11
|
+
add_index :product_instances, :product_type_id
|
12
|
+
|
13
|
+
add_index :product_offers, [:product_offer_record_id, :product_offer_record_type],
|
14
|
+
:name => "bpi_3"
|
15
|
+
|
16
|
+
add_index :simple_product_offers, :product_id
|
17
|
+
|
18
|
+
add_index :prod_instance_reln_types, :parent_id
|
19
|
+
|
20
|
+
add_index :prod_instance_role_types, :parent_id
|
21
|
+
|
22
|
+
add_index :prod_instance_relns, :prod_instance_reln_type_id
|
23
|
+
add_index :prod_instance_relns, :status_type_id
|
24
|
+
|
25
|
+
add_index :prod_type_reln_types, :parent_id
|
26
|
+
|
27
|
+
add_index :prod_type_role_types, :parent_id
|
28
|
+
|
29
|
+
add_index :prod_type_relns, :prod_type_reln_type_id
|
30
|
+
add_index :prod_type_relns, :status_type_id
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.down
|
34
|
+
remove_index :product_types, :parent_id
|
35
|
+
remove_index :product_types, :name => "bpi_1"
|
36
|
+
|
37
|
+
remove_index :product_instances, :parent_id
|
38
|
+
remove_index :product_instances, :name => "bpi_2"
|
39
|
+
remove_index :product_instances, :product_type_id
|
40
|
+
|
41
|
+
remove_index :product_offers, :name => "bpi_3"
|
42
|
+
|
43
|
+
remove_index :simple_product_offers, :product_id
|
44
|
+
|
45
|
+
remove_index :prod_instance_reln_types, :parent_id
|
46
|
+
|
47
|
+
remove_index :prod_instance_role_types, :parent_id
|
48
|
+
|
49
|
+
remove_index :prod_instance_relns, :prod_instance_reln_type_id
|
50
|
+
remove_index :prod_instance_relns, :status_type_id
|
51
|
+
|
52
|
+
remove_index :prod_type_reln_types, :parent_id
|
53
|
+
|
54
|
+
remove_index :prod_type_role_types, :parent_id
|
55
|
+
|
56
|
+
remove_index :prod_type_relns, :prod_type_reln_type_id
|
57
|
+
remove_index :prod_type_relns, :status_type_id
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,271 @@
|
|
1
|
+
# This migration comes from erp_tech_svcs (originally 20080805000010)
|
2
|
+
class BaseTechServices < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
unless table_exists?(:users)
|
5
|
+
# Create the users table
|
6
|
+
create_table :users do |t|
|
7
|
+
t.string :username
|
8
|
+
t.string :email
|
9
|
+
t.references :party
|
10
|
+
t.string :type
|
11
|
+
t.string :salt, :default => nil
|
12
|
+
t.string :crypted_password, :default => nil
|
13
|
+
|
14
|
+
#activity logging
|
15
|
+
t.datetime :last_login_at, :default => nil
|
16
|
+
t.datetime :last_logout_at, :default => nil
|
17
|
+
t.datetime :last_activity_at, :default => nil
|
18
|
+
|
19
|
+
#brute force protection
|
20
|
+
t.integer :failed_logins_count, :default => 0
|
21
|
+
t.datetime :lock_expires_at, :default => nil
|
22
|
+
|
23
|
+
#remember me
|
24
|
+
t.string :remember_me_token, :default => nil
|
25
|
+
t.datetime :remember_me_token_expires_at, :default => nil
|
26
|
+
|
27
|
+
#reset password
|
28
|
+
t.string :reset_password_token, :default => nil
|
29
|
+
t.datetime :reset_password_token_expires_at, :default => nil
|
30
|
+
t.datetime :reset_password_email_sent_at, :default => nil
|
31
|
+
|
32
|
+
#user activation
|
33
|
+
t.string :activation_state, :default => nil
|
34
|
+
t.string :activation_token, :default => nil
|
35
|
+
t.datetime :activation_token_expires_at, :default => nil
|
36
|
+
|
37
|
+
t.string :security_question_1
|
38
|
+
t.string :security_answer_1
|
39
|
+
t.string :security_question_2
|
40
|
+
t.string :security_answer_2
|
41
|
+
|
42
|
+
t.timestamps
|
43
|
+
end
|
44
|
+
add_index :users, :email, :unique => true
|
45
|
+
add_index :users, :username, :unique => true
|
46
|
+
add_index :users, [:last_logout_at, :last_activity_at], :name => 'activity_idx'
|
47
|
+
add_index :users, :remember_me_token
|
48
|
+
add_index :users, :reset_password_token
|
49
|
+
add_index :users, :activation_token
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
unless table_exists?(:groups)
|
54
|
+
create_table :groups do |t|
|
55
|
+
t.column :description, :string
|
56
|
+
t.timestamps
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
unless table_exists?(:security_roles)
|
61
|
+
# create the roles table
|
62
|
+
create_table :security_roles do |t|
|
63
|
+
t.column :description, :string
|
64
|
+
t.column :internal_identifier, :string
|
65
|
+
t.column :external_identifier, :string
|
66
|
+
t.column :external_id_source, :string
|
67
|
+
|
68
|
+
t.timestamps
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
unless table_exists?(:sessions)
|
73
|
+
# Create sessions table
|
74
|
+
create_table :sessions do |t|
|
75
|
+
t.string :session_id, :null => false
|
76
|
+
t.text :data
|
77
|
+
t.timestamps
|
78
|
+
end
|
79
|
+
add_index :sessions, :session_id
|
80
|
+
add_index :sessions, :updated_at
|
81
|
+
end
|
82
|
+
|
83
|
+
unless table_exists?(:audit_logs)
|
84
|
+
# Create audit_logs
|
85
|
+
create_table :audit_logs do |t|
|
86
|
+
t.string :application
|
87
|
+
t.string :description
|
88
|
+
t.integer :party_id
|
89
|
+
t.text :additional_info
|
90
|
+
t.references :audit_log_type
|
91
|
+
|
92
|
+
#polymorphic columns
|
93
|
+
t.references :event_record, :polymorphic => true
|
94
|
+
|
95
|
+
t.timestamps
|
96
|
+
end
|
97
|
+
add_index :audit_logs, :party_id
|
98
|
+
add_index :audit_logs, [:event_record_id, :event_record_type], :name => 'event_record_index'
|
99
|
+
end
|
100
|
+
|
101
|
+
unless table_exists?(:audit_log_types)
|
102
|
+
# Create audit_logs
|
103
|
+
create_table :audit_log_types do |t|
|
104
|
+
t.string :description
|
105
|
+
t.string :error_code
|
106
|
+
t.string :comments
|
107
|
+
t.string :internal_identifier
|
108
|
+
t.string :external_identifier
|
109
|
+
t.string :external_id_source
|
110
|
+
|
111
|
+
#better nested set columns
|
112
|
+
t.integer :parent_id
|
113
|
+
t.integer :lft
|
114
|
+
t.integer :rgt
|
115
|
+
|
116
|
+
t.timestamps
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
unless table_exists?(:audit_log_items)
|
121
|
+
# Create audit_log_items
|
122
|
+
create_table :audit_log_items do |t|
|
123
|
+
t.references :audit_log
|
124
|
+
t.references :audit_log_item_type
|
125
|
+
t.string :audit_log_item_value
|
126
|
+
t.string :description
|
127
|
+
|
128
|
+
t.timestamps
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
unless table_exists?(:audit_log_item_types)
|
133
|
+
# Create audit_log_item_types
|
134
|
+
create_table :audit_log_item_types do |t|
|
135
|
+
t.string :internal_identifier
|
136
|
+
t.string :external_identifier
|
137
|
+
t.string :external_id_source
|
138
|
+
t.string :description
|
139
|
+
t.string :comments
|
140
|
+
|
141
|
+
#better nested set columns
|
142
|
+
t.integer :parent_id
|
143
|
+
t.integer :lft
|
144
|
+
t.integer :rgt
|
145
|
+
|
146
|
+
t.timestamps
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
unless table_exists?(:file_assets)
|
151
|
+
create_table :file_assets do |t|
|
152
|
+
t.references :file_asset_holder, :polymorphic => true
|
153
|
+
t.string :type
|
154
|
+
t.string :name
|
155
|
+
t.string :directory
|
156
|
+
t.string :data_file_name
|
157
|
+
t.string :data_content_type
|
158
|
+
t.integer :data_file_size
|
159
|
+
t.datetime :data_updated_at
|
160
|
+
t.string :width
|
161
|
+
t.string :height
|
162
|
+
|
163
|
+
t.timestamps
|
164
|
+
end
|
165
|
+
add_index :file_assets, :type
|
166
|
+
add_index :file_assets, [:file_asset_holder_id, :file_asset_holder_type], :name => 'file_asset_holder_idx'
|
167
|
+
add_index :file_assets, :name
|
168
|
+
add_index :file_assets, :directory
|
169
|
+
end
|
170
|
+
|
171
|
+
unless table_exists?(:delayed_jobs)
|
172
|
+
create_table :delayed_jobs, :force => true do |table|
|
173
|
+
table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
|
174
|
+
table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
|
175
|
+
table.text :handler # YAML-encoded string of the object that will do work
|
176
|
+
table.text :last_error # reason for last failure (See Note below)
|
177
|
+
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
|
178
|
+
table.datetime :locked_at # Set when a client is working on this object
|
179
|
+
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
|
180
|
+
table.string :locked_by # Who is working on this object (if locked)
|
181
|
+
table.string :queue
|
182
|
+
table.timestamps
|
183
|
+
end
|
184
|
+
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
|
185
|
+
end
|
186
|
+
|
187
|
+
unless table_exists?(:capable_models)
|
188
|
+
# create the roles table
|
189
|
+
create_table :capable_models do |t|
|
190
|
+
t.references :capable_model_record, :polymorphic => true
|
191
|
+
|
192
|
+
t.timestamps
|
193
|
+
end
|
194
|
+
|
195
|
+
add_index :capable_models, [:capable_model_record_id, :capable_model_record_type], :name => 'capable_model_record_idx'
|
196
|
+
end
|
197
|
+
|
198
|
+
unless table_exists?(:capability_types)
|
199
|
+
# create the roles table
|
200
|
+
create_table :capability_types do |t|
|
201
|
+
t.string :internal_identifier
|
202
|
+
t.string :description
|
203
|
+
t.timestamps
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
unless table_exists?(:capabilities)
|
208
|
+
# create the roles table
|
209
|
+
create_table :capabilities do |t|
|
210
|
+
t.string :description
|
211
|
+
t.references :capability_type
|
212
|
+
t.string :capability_resource_type
|
213
|
+
t.integer :capability_resource_id
|
214
|
+
t.integer :scope_type_id
|
215
|
+
t.text :scope_query
|
216
|
+
t.timestamps
|
217
|
+
end
|
218
|
+
|
219
|
+
add_index :capabilities, :capability_type_id
|
220
|
+
add_index :capabilities, :scope_type_id
|
221
|
+
add_index :capabilities, [:capability_resource_id, :capability_resource_type], :name => 'capability_resource_index'
|
222
|
+
end
|
223
|
+
|
224
|
+
unless table_exists?(:capability_accessors)
|
225
|
+
create_table :capability_accessors do |t|
|
226
|
+
t.string :capability_accessor_record_type
|
227
|
+
t.integer :capability_accessor_record_id
|
228
|
+
t.integer :capability_id
|
229
|
+
t.timestamps
|
230
|
+
end
|
231
|
+
|
232
|
+
add_index :capability_accessors, :capability_id
|
233
|
+
add_index :capability_accessors, [:capability_accessor_record_id, :capability_accessor_record_type], :name => 'capability_accessor_record_index'
|
234
|
+
end
|
235
|
+
|
236
|
+
unless table_exists?(:scope_types)
|
237
|
+
create_table :scope_types do |t|
|
238
|
+
t.string :description
|
239
|
+
t.string :internal_identifier
|
240
|
+
t.timestamps
|
241
|
+
end
|
242
|
+
|
243
|
+
add_index :scope_types, :internal_identifier
|
244
|
+
end
|
245
|
+
|
246
|
+
unless table_exists?(:parties_security_roles)
|
247
|
+
create_table :parties_security_roles, :id => false do |t|
|
248
|
+
t.integer :party_id
|
249
|
+
t.integer :security_role_id
|
250
|
+
end
|
251
|
+
|
252
|
+
add_index :parties_security_roles, :party_id
|
253
|
+
add_index :parties_security_roles, :security_role_id
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
def self.down
|
259
|
+
# check that each table exists before trying to delete it.
|
260
|
+
[ :groups,
|
261
|
+
:audit_logs, :sessions, :simple_captcha_data,
|
262
|
+
:capability_accessors, :capability_types, :capabilities,:scope_types,
|
263
|
+
:parties_security_roles, :roles, :audit_log_items, :audit_log_item_types,
|
264
|
+
:users, :file_assets, :delayed_jobs
|
265
|
+
].each do |tbl|
|
266
|
+
if table_exists?(tbl)
|
267
|
+
drop_table tbl
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|