erp_invoicing 3.0.6 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/app/models/billing_account.rb +5 -3
  2. data/app/models/calculate_balance_strategy_type.rb +2 -0
  3. data/app/models/invoice.rb +2 -0
  4. data/app/models/invoice_item.rb +1 -0
  5. data/app/models/invoice_item_type.rb +1 -0
  6. data/app/models/invoice_party_role.rb +1 -0
  7. data/app/models/invoice_payment_strategy_type.rb +2 -0
  8. data/app/models/invoice_payment_term.rb +2 -0
  9. data/app/models/invoice_payment_term_set.rb +2 -0
  10. data/app/models/invoice_payment_term_type.rb +2 -0
  11. data/app/models/invoice_type.rb +1 -0
  12. data/app/models/payment_application.rb +2 -1
  13. data/app/models/recurring_payment.rb +2 -0
  14. data/db/migrate/20111121000000_invoicing_services.rb +13 -1
  15. data/lib/erp_invoicing/version.rb +2 -2
  16. data/lib/erp_invoicing.rb +4 -0
  17. data/public/javascripts/erp_app/desktop/applications/invoice_management/billing_accounts_panel.js +0 -1
  18. data/public/javascripts/erp_app/shared/invoices_grid_panel.js +1 -1
  19. data/spec/dummy/config/application.rb +6 -0
  20. data/spec/dummy/config/environments/spec.rb +3 -0
  21. data/spec/dummy/db/data_migrations/20101011152441_payment_gateway_actions.erp_commerce.rb +28 -0
  22. data/spec/dummy/db/data_migrations/20101014142230_financial_txn_types.erp_txns_and_accts.rb +16 -0
  23. data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
  24. data/spec/dummy/db/data_migrations/20110324010232_product_role_types.erp_products.rb +24 -0
  25. data/spec/dummy/db/data_migrations/20110509223702_add_publisher_role.knitkit.rb +22 -0
  26. data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
  27. data/spec/dummy/db/data_migrations/20110527160807_add_default_prod_avail_types.erp_products.rb +27 -0
  28. data/spec/dummy/db/data_migrations/20110605231556_create_order_party_roles.erp_orders.rb +24 -0
  29. data/spec/dummy/db/data_migrations/20110608185830_create_default_dynamic_models_and_forms.erp_forms.rb +33 -0
  30. data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
  31. data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +252 -0
  32. data/spec/dummy/db/data_migrations/20110728201730_create_desktop_app_product_manager.erp_products.rb +26 -0
  33. data/spec/dummy/db/data_migrations/20110728201731_create_desktop_app_order_manager.erp_orders.rb +26 -0
  34. data/spec/dummy/db/data_migrations/20110728201732_create_organizer_app_order_management.erp_orders.rb +15 -0
  35. data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +53 -0
  36. data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
  37. data/spec/dummy/db/data_migrations/20110816153456_add_knitkit_application.knitkit.rb +32 -0
  38. data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +21 -0
  39. data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +32 -0
  40. data/spec/dummy/db/data_migrations/20110828190913_create_desktop_app_dynamic_forms.erp_forms.rb +19 -0
  41. data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
  42. data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +23 -0
  43. data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +42 -0
  44. data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
  45. data/spec/dummy/db/data_migrations/20111118182910_setup_knitkit_capabilities.knitkit.rb +128 -0
  46. data/spec/dummy/db/data_migrations/20111121153349_create_bill_pay_organizer_application.erp_invoicing.rb +15 -0
  47. data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
  48. data/spec/dummy/db/data_migrations/20120118181839_create_invoice_management_desktop_application.erp_invoicing.rb +27 -0
  49. data/spec/dummy/db/data_migrations/20120127144444_create_website_role_types.knitkit.rb +14 -0
  50. data/spec/dummy/db/data_migrations/20120127150505_create_website_default_configuration.knitkit.rb +73 -0
  51. data/spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb +34 -0
  52. data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
  53. data/spec/dummy/db/data_migrations/20120229174322_add_billpay_widget.erp_invoicing.rb +27 -0
  54. data/spec/dummy/db/data_migrations/20120229174343_add_orders_widget.erp_orders.rb +29 -0
  55. data/spec/dummy/db/data_migrations/20120316150424_add_is_template_to_default_website_config.knitkit.rb +17 -0
  56. data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
  57. data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +19 -0
  58. data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +23 -0
  59. data/spec/dummy/db/data_migrations/20120605154637_add_calculate_balance_strategy_types.erp_invoicing.rb +21 -0
  60. data/spec/dummy/db/data_migrations/20120809020508_update_website_and_configuration.knitkit.rb +78 -0
  61. data/spec/dummy/db/data_migrations/20120824013449_create_ticket_form.erp_forms.rb +67 -0
  62. data/spec/dummy/db/data_migrations/20121026013449_update_ticket_form.erp_forms.rb +65 -0
  63. data/spec/dummy/db/data_migrations/20121026191738_update_contact_form.erp_forms.rb +27 -0
  64. data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
  65. data/spec/dummy/db/data_migrations/20121129185611_upgrade_website_role_iid.knitkit.rb +21 -0
  66. data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
  67. data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
  68. data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +23 -0
  69. data/spec/dummy/db/migrate/20121214000230_base_erp_services.erp_base_erp_svcs.rb +461 -0
  70. data/spec/dummy/db/migrate/20121214000231_base_tech_services.erp_tech_svcs.rb +255 -0
  71. data/spec/dummy/db/migrate/20121214000232_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
  72. data/spec/dummy/db/migrate/20121214000233_base_app_framework.erp_app.rb +276 -0
  73. data/spec/dummy/db/migrate/20121214000234_dynamic_forms.erp_forms.rb +95 -0
  74. data/spec/dummy/db/migrate/20121214000235_create_tickets.erp_forms.rb +19 -0
  75. data/spec/dummy/db/migrate/20121214000236_upgrade_dynamic_forms_table.erp_forms.rb +32 -0
  76. data/spec/dummy/db/migrate/20121214000237_setup_knitkit.knitkit.rb +316 -0
  77. data/spec/dummy/db/migrate/20121214000238_invoicing_services.erp_invoicing.rb +277 -0
  78. data/spec/dummy/db/migrate/20121214000239_base_inventory.erp_inventory.rb +91 -0
  79. data/spec/dummy/db/migrate/20121214000240_base_inventory_indexes.erp_inventory.rb +48 -0
  80. data/spec/dummy/db/migrate/20121214000241_base_txns_and_accts.erp_txns_and_accts.rb +364 -0
  81. data/spec/dummy/db/migrate/20121214000242_agreements_services.erp_agreements.rb +160 -0
  82. data/spec/dummy/db/migrate/20121214000243_agreements_services_indexes.erp_agreements.rb +52 -0
  83. data/spec/dummy/db/migrate/20121214000244_base_orders.erp_orders.rb +178 -0
  84. data/spec/dummy/db/migrate/20121214000245_base_products.erp_products.rb +234 -0
  85. data/spec/dummy/db/migrate/20121214000246_base_products_indexes.erp_products.rb +59 -0
  86. data/spec/dummy/db/migrate/20121214000247_erp_commerce_base.erp_commerce.rb +442 -0
  87. data/spec/dummy/db/migrate/20121214000248_base_work_efforts.erp_work_effort.rb +211 -0
  88. data/spec/dummy/db/migrate/20130107181155_create_groups.erp_tech_svcs.rb +19 -0
  89. data/spec/dummy/db/migrate/20130107181156_upgrade_security.erp_tech_svcs.rb +54 -0
  90. data/spec/dummy/db/migrate/20130107181157_upgrade_security2.erp_tech_svcs.rb +270 -0
  91. data/spec/dummy/db/schema.rb +2569 -0
  92. data/spec/dummy/db/spec.sqlite3 +0 -0
  93. data/spec/dummy/log/spec.log +64744 -0
  94. data/spec/models/billing_account_spec.rb +1 -7
  95. data/spec/models/invoice_spec.rb +2 -1
  96. data/spec/models/payment_application_spec.rb +1 -1
  97. data/spec/spec_helper.rb +18 -10
  98. metadata +203 -20
  99. data/db/migrate/20120228184317_add_text_to_pay_to_recurring_payments.rb +0 -13
  100. data/db/migrate/20120301155722_add_billing_date_to_billing_account.rb +0 -13
  101. data/db/migrate/20120605144227_create_calcuate_balance_strategy_type.rb +0 -18
  102. data/db/migrate/20120605144900_add_calculate_balance_strategy_to_billing_account.rb +0 -7
  103. data/db/migrate/20120605150425_add_balance_to_invoice.rb +0 -9
@@ -0,0 +1,95 @@
1
+ # This migration comes from erp_forms (originally 20110530193446)
2
+ class DynamicForms < ActiveRecord::Migration
3
+ def self.up
4
+ unless table_exists?(:dynamic_form_models)
5
+ create_table :dynamic_form_models do |t|
6
+ t.string :model_name
7
+ t.boolean :show_in_multitask, :default => false
8
+ t.boolean :allow_comments, :default => true
9
+ t.boolean :allow_files, :default => true
10
+ t.string :file_security_default, :default => 'private'
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+
16
+ unless table_exists?(:dynamic_form_documents)
17
+ create_table :dynamic_form_documents do |t|
18
+ t.integer :dynamic_form_model_id
19
+ t.string :type
20
+
21
+ t.timestamps
22
+ end
23
+
24
+ add_index :dynamic_form_documents, :dynamic_form_model_id
25
+ add_index :dynamic_form_documents, :type
26
+ end
27
+
28
+ unless table_exists?(:dynamic_forms)
29
+ create_table :dynamic_forms do |t|
30
+ t.string :description
31
+ t.text :definition
32
+ t.integer :dynamic_form_model_id
33
+ t.string :model_name
34
+ t.string :internal_identifier
35
+ t.boolean :default
36
+ t.string :widget_action, :default => 'save'
37
+ t.string :widget_email_recipients
38
+ t.boolean :focus_first_field, :default => true
39
+ t.boolean :submit_empty_text, :default => false
40
+ t.string :msg_target, :default => 'qtip'
41
+ t.string :submit_button_label, :default => 'Submit'
42
+ t.string :cancel_button_label, :default => 'Cancel'
43
+ t.text :comment
44
+
45
+ t.integer :created_by_id
46
+ t.integer :updated_by_id
47
+
48
+ t.timestamps
49
+ end
50
+
51
+ add_index :dynamic_forms, :created_by_id
52
+ add_index :dynamic_forms, :updated_by_id
53
+ add_index :dynamic_forms, :dynamic_form_model_id
54
+ add_index :dynamic_forms, :model_name
55
+ add_index :dynamic_forms, :internal_identifier
56
+ end
57
+
58
+ unless table_exists?(:dynamic_data)
59
+ create_table :dynamic_data do |t|
60
+ t.string :reference_type
61
+ t.integer :reference_id
62
+ t.text :dynamic_attributes
63
+
64
+ t.integer :created_with_form_id
65
+ t.integer :updated_with_form_id
66
+
67
+ t.integer :created_by_id
68
+ t.integer :updated_by_id
69
+
70
+ t.timestamps
71
+ end
72
+
73
+ add_index :dynamic_data, :created_with_form_id
74
+ add_index :dynamic_data, :updated_with_form_id
75
+ add_index :dynamic_data, :created_by_id
76
+ add_index :dynamic_data, :updated_by_id
77
+ add_index :dynamic_data, :reference_type
78
+ add_index :dynamic_data, :reference_id
79
+ end
80
+
81
+ end
82
+
83
+ def self.down
84
+ [ :dynamic_form_models,
85
+ :dynamic_form_documents,
86
+ :dynamic_forms,
87
+ :dynamic_data
88
+ ].each do |tbl|
89
+ if table_exists?(tbl)
90
+ drop_table tbl
91
+ end
92
+ end
93
+
94
+ end
95
+ end
@@ -0,0 +1,19 @@
1
+ # This migration comes from erp_forms (originally 20120824012520)
2
+ class CreateTickets < ActiveRecord::Migration
3
+
4
+ def up
5
+ unless table_exists?(:tickets)
6
+ create_table :tickets do |t|
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ end
12
+
13
+ def down
14
+ if table_exists?(:tickets)
15
+ drop_table :tickets
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,32 @@
1
+ # This migration comes from erp_forms (originally 20121007022323)
2
+ class UpgradeDynamicFormsTable < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :dynamic_form_models, :show_in_multitask, :boolean, :default => false unless columns(:dynamic_form_models).collect {|c| c.name}.include?('show_in_multitask')
5
+ add_column :dynamic_form_models, :allow_comments, :boolean, :default => true unless columns(:dynamic_form_models).collect {|c| c.name}.include?('allow_comments')
6
+ add_column :dynamic_form_models, :allow_files, :boolean, :default => true unless columns(:dynamic_form_models).collect {|c| c.name}.include?('allow_files')
7
+ add_column :dynamic_form_models, :file_security_default, :string, :default => 'private' unless columns(:dynamic_form_models).collect {|c| c.name}.include?('file_security_default')
8
+ add_column :dynamic_forms, :widget_action, :string, :default => 'save' unless columns(:dynamic_forms).collect {|c| c.name}.include?('widget_action')
9
+ add_column :dynamic_forms, :widget_email_recipients, :string unless columns(:dynamic_forms).collect {|c| c.name}.include?('widget_email_recipients')
10
+ add_column :dynamic_forms, :focus_first_field, :boolean, :default => true unless columns(:dynamic_forms).collect {|c| c.name}.include?('focus_first_field')
11
+ add_column :dynamic_forms, :submit_empty_text, :boolean, :default => false unless columns(:dynamic_forms).collect {|c| c.name}.include?('submit_empty_text')
12
+ add_column :dynamic_forms, :msg_target, :string, :default => 'qtip' unless columns(:dynamic_forms).collect {|c| c.name}.include?('msg_target')
13
+ add_column :dynamic_forms, :submit_button_label, :string, :default => 'Submit' unless columns(:dynamic_forms).collect {|c| c.name}.include?('submit_button_label')
14
+ add_column :dynamic_forms, :cancel_button_label, :string, :default => 'Cancel' unless columns(:dynamic_forms).collect {|c| c.name}.include?('cancel_button_label')
15
+ add_column :dynamic_forms, :comment, :text unless columns(:dynamic_forms).collect {|c| c.name}.include?('comment')
16
+ end
17
+
18
+ def self.down
19
+ remove_column :dynamic_form_models, :show_in_multitask if columns(:dynamic_form_models).collect {|c| c.name}.include?('show_in_multitask')
20
+ remove_column :dynamic_form_models, :file_security_default if columns(:dynamic_form_models).collect {|c| c.name}.include?('file_security_default')
21
+ remove_column :dynamic_form_models, :allow_files if columns(:dynamic_form_models).collect {|c| c.name}.include?('allow_files')
22
+ remove_column :dynamic_form_models, :allow_comments if columns(:dynamic_form_models).collect {|c| c.name}.include?('allow_comments')
23
+ remove_column :dynamic_forms, :widget_action if columns(:dynamic_forms).collect {|c| c.name}.include?('widget_action')
24
+ remove_column :dynamic_forms, :widget_email_recipients if columns(:dynamic_forms).collect {|c| c.name}.include?('widget_email_recipients')
25
+ remove_column :dynamic_forms, :focus_first_field if columns(:dynamic_forms).collect {|c| c.name}.include?('focus_first_field')
26
+ remove_column :dynamic_forms, :submit_empty_text if columns(:dynamic_forms).collect {|c| c.name}.include?('submit_empty_text')
27
+ remove_column :dynamic_forms, :msg_target if columns(:dynamic_forms).collect {|c| c.name}.include?('msg_target')
28
+ remove_column :dynamic_forms, :submit_button_label if columns(:dynamic_forms).collect {|c| c.name}.include?('submit_button_label')
29
+ remove_column :dynamic_forms, :cancel_button_label if columns(:dynamic_forms).collect {|c| c.name}.include?('cancel_button_label')
30
+ remove_column :dynamic_forms, :comment if columns(:dynamic_forms).collect {|c| c.name}.include?('comment')
31
+ end
32
+ end
@@ -0,0 +1,316 @@
1
+ # This migration comes from knitkit (originally 20110211002317)
2
+ class SetupKnitkit < ActiveRecord::Migration
3
+ def self.up
4
+
5
+ unless table_exists?(:websites)
6
+ create_table :websites do |t|
7
+ t.string :name
8
+ t.string :title
9
+ t.string :subtitle
10
+ t.string :internal_identifier
11
+ t.string :email
12
+ t.boolean :auto_activate_publication
13
+ t.boolean :email_inquiries
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+
19
+ unless table_exists?(:website_hosts)
20
+ create_table :website_hosts do |t|
21
+ t.references :website
22
+ t.string :host
23
+
24
+ t.timestamps
25
+ end
26
+
27
+ add_index :website_hosts, :website_id
28
+ end
29
+
30
+ unless table_exists?(:website_inquiries)
31
+ create_table :website_inquiries do |t|
32
+ t.integer :website_id
33
+
34
+ t.timestamps
35
+ end
36
+
37
+ add_index :website_inquiries, :website_id
38
+ end
39
+
40
+ unless table_exists?(:website_sections)
41
+ create_table :website_sections do |t|
42
+ t.string :title
43
+ t.string :type
44
+ t.references :website
45
+ t.string :path
46
+ t.string :permalink
47
+ t.text :layout
48
+ t.boolean :in_menu
49
+ t.integer :position, :default => 0
50
+ t.string :internal_identifier
51
+ t.integer :version
52
+ t.boolean :render_base_layout, :default => true
53
+
54
+ #better nested set columns
55
+ t.integer :parent_id
56
+ t.integer :lft
57
+ t.integer :rgt
58
+
59
+ t.timestamps
60
+ end
61
+ #indexes
62
+ add_index :website_sections, :permalink
63
+ add_index :website_sections, :website_id
64
+ add_index :website_sections, :position
65
+ add_index :website_sections, :parent_id
66
+ add_index :website_sections, :lft
67
+ add_index :website_sections, :rgt
68
+ add_index :website_sections, :version
69
+ add_index :website_sections, :internal_identifier, :name => 'section_iid_idx'
70
+
71
+ WebsiteSection.create_versioned_table
72
+ end
73
+
74
+ unless table_exists?(:contents)
75
+ create_table :contents do |t|
76
+ t.string :type
77
+ t.string :title
78
+ t.string :permalink
79
+ t.text :excerpt_html
80
+ t.text :body_html
81
+ t.integer :created_by_id
82
+ t.integer :updated_by_id
83
+ t.string :internal_identifier
84
+ t.boolean :display_title
85
+ t.integer :version
86
+
87
+ t.timestamps
88
+ end
89
+ #indexes
90
+ add_index :contents, :type
91
+ add_index :contents, :created_by_id
92
+ add_index :contents, :updated_by_id
93
+ add_index :contents, :permalink
94
+ add_index :contents, :version
95
+ add_index :contents, :internal_identifier, :name => 'contents_iid_idx'
96
+
97
+ Content.create_versioned_table
98
+ end
99
+
100
+ unless table_exists?(:website_section_contents)
101
+ create_table :website_section_contents do |t|
102
+ t.integer :website_section_id
103
+ t.integer :content_id
104
+ t.string :content_area
105
+ t.integer :position, :default => 0
106
+
107
+ t.timestamps
108
+ end
109
+ #indexes
110
+ add_index :website_section_contents, :website_section_id
111
+ add_index :website_section_contents, :content_id
112
+ add_index :website_section_contents, :position
113
+ add_index :website_section_contents, :content_area
114
+ end
115
+
116
+ unless table_exists?(:themes)
117
+ create_table :themes do |t|
118
+ t.references :website
119
+ t.string :name
120
+ t.string :theme_id
121
+ t.string :author
122
+ t.integer :version
123
+ t.string :homepage
124
+ t.text :summary
125
+ t.integer :active
126
+
127
+ t.timestamps
128
+ end
129
+ #indexes
130
+ add_index :themes, :website_id
131
+ add_index :themes, :active
132
+ end
133
+
134
+ unless table_exists?(:published_websites)
135
+ create_table :published_websites do |t|
136
+ t.references :website
137
+ t.text :comment
138
+ t.decimal :version, :precision => 18, :scale => 6
139
+ t.boolean :active
140
+ t.integer :published_by_id
141
+
142
+ t.timestamps
143
+ end
144
+
145
+ #indexes
146
+ add_index :published_websites, :website_id
147
+ add_index :published_websites, :version
148
+ add_index :published_websites, :active
149
+ add_index :published_websites, :published_by_id
150
+ end
151
+
152
+ unless table_exists?(:published_elements)
153
+ create_table :published_elements do |t|
154
+ t.references :published_website
155
+ t.references :published_element_record, :polymorphic => true
156
+ t.integer :version
157
+ t.integer :published_by_id
158
+
159
+ t.timestamps
160
+ end
161
+
162
+ #indexes
163
+ add_index :published_elements, [:published_element_record_id, :published_element_record_type], :name => 'published_elm_idx'
164
+ add_index :published_elements, :published_website_id
165
+ add_index :published_elements, :version
166
+ add_index :published_elements, :published_by_id
167
+ end
168
+
169
+ unless table_exists?(:comments)
170
+ create_table :comments do |t|
171
+ t.string :commentor_name
172
+ t.string :email
173
+ t.text :comment
174
+ t.integer :approved
175
+ t.datetime :approved_at
176
+ t.references :user
177
+ t.references :commented_record, :polymorphic => true
178
+
179
+ t.timestamps
180
+ end
181
+
182
+ add_index :comments, [:commented_record_id, :commented_record_type], :name => 'commented_record_idx'
183
+ add_index :comments, [:approved]
184
+ add_index :comments, [:user_id]
185
+ end
186
+
187
+ unless table_exists?(:website_nav_items)
188
+ create_table :website_nav_items do |t|
189
+ t.references :website_nav
190
+ t.string :title
191
+ t.string :url
192
+ t.integer :position, :default => 0
193
+ t.references :linked_to_item, :polymorphic => true
194
+
195
+ #better nested set columns
196
+ t.integer :parent_id
197
+ t.integer :lft
198
+ t.integer :rgt
199
+
200
+ t.timestamps
201
+ end
202
+
203
+ add_index :website_nav_items, [:linked_to_item_id, :linked_to_item_type], :name => 'linked_to_idx'
204
+ add_index :website_nav_items, :website_nav_id
205
+ add_index :website_nav_items, :position
206
+ add_index :website_nav_items, :parent_id
207
+ add_index :website_nav_items, :lft
208
+ add_index :website_nav_items, :rgt
209
+ end
210
+
211
+ unless table_exists?(:website_navs)
212
+ create_table :website_navs do |t|
213
+ t.references :website
214
+ t.string :name
215
+
216
+ t.timestamps
217
+ end
218
+
219
+ add_index :website_navs, :website_id
220
+ end
221
+
222
+ unless table_exists?(:tags)
223
+ create_table :tags do |t|
224
+ t.column :name, :string
225
+ end
226
+ end
227
+
228
+ unless table_exists?(:taggings)
229
+ create_table :taggings do |t|
230
+ t.column :tag_id, :integer
231
+ t.column :taggable_id, :integer
232
+ t.column :tagger_id, :integer
233
+ t.column :tagger_type, :string
234
+
235
+ # You should make sure that the column created is
236
+ # long enough to store the required class names.
237
+ t.column :taggable_type, :string
238
+ t.column :context, :string
239
+
240
+ t.column :created_at, :datetime
241
+ end
242
+
243
+ add_index :taggings, :tag_id
244
+ add_index :taggings, [:taggable_id, :taggable_type, :context], :name => 'taggable_poly_idx'
245
+ end
246
+
247
+ unless table_exists? :website_party_roles
248
+ create_table :website_party_roles do |t|
249
+ #foreign keys
250
+ t.references :website
251
+ t.references :role_type
252
+ t.references :party
253
+
254
+ t.timestamps
255
+ end
256
+
257
+ add_index :website_party_roles, :website_id
258
+ add_index :website_party_roles, :role_type_id
259
+ add_index :website_party_roles, :party_id
260
+ end
261
+
262
+ create_table :documented_items, :force => true do |t|
263
+ t.string :documented_klass, :null => true
264
+ t.integer :documented_content_id, :null => true
265
+ t.integer :online_document_section_id
266
+ t.timestamps
267
+ end
268
+
269
+ create_table :documents do |t|
270
+ t.string :external_identifier
271
+ t.string :internal_identifier
272
+ t.string :description
273
+ t.datetime :document_date
274
+ t.text :dynamic_attributes
275
+
276
+ t.references :document_record, :polymorphic => true
277
+ t.references :document_type
278
+
279
+ t.timestamps
280
+ end
281
+
282
+ add_index :documents, [:document_record_type, :document_record_id], :name => 'document_record_poly_idx'
283
+ add_index :documents, :document_type_id, :name => 'document_type_idx'
284
+
285
+ create_table :document_types do |t|
286
+ t.string :external_identifier
287
+ t.string :internal_identifier
288
+ t.string :description
289
+
290
+ t.timestamps
291
+ end
292
+
293
+ create_table :valid_documents do |t|
294
+ t.references :document
295
+ t.references :documented_model, :polymorphic => true
296
+ end
297
+
298
+ add_index :valid_documents, :document_id
299
+ add_index :valid_documents, [:documented_model_id, :documented_model_type], :name => 'valid_documents_model_idx'
300
+
301
+ end
302
+
303
+ def self.down
304
+ WebsiteSection.drop_versioned_table
305
+ Content.drop_versioned_table
306
+
307
+ # check that each table exists before trying to delete it.
308
+ [:websites, :website_sections, :contents, :website_section_contents, :documents, :document_types, :valid_documents,
309
+ :themes, :theme_files, :published_websites, :published_elements, :website_party_roles,
310
+ :comments,:website_hosts,:website_nav_items, :website_navs, :tags, :taggings, :documented_items].each do |tbl|
311
+ if table_exists?(tbl)
312
+ drop_table tbl
313
+ end
314
+ end
315
+ end
316
+ end