erp_search 3.0.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/extensions/dynamic_form_document.rb +3 -0
- data/app/models/extensions/ticket.rb +3 -0
- data/app/models/extensions/website_inquiry.rb +3 -0
- data/app/models/party_search_fact.rb +2 -0
- data/config/sunspot.yml +11 -4
- data/lib/erp_search.rb +7 -0
- data/lib/erp_search/engine.rb +5 -2
- data/lib/erp_search/extensions.rb +2 -0
- data/lib/erp_search/extensions/active_record/has_dynamic_solr_search.rb +116 -0
- data/lib/erp_search/version.rb +2 -2
- data/lib/tasks/dynamic_form_models.rake +42 -0
- data/spec/dummy/config/application.rb +6 -0
- data/spec/dummy/config/environments/spec.rb +3 -0
- data/spec/dummy/config/sunspot.yml +36 -0
- data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
- data/spec/dummy/db/data_migrations/20110509223702_add_publisher_role.knitkit.rb +22 -0
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20110608185830_create_default_dynamic_models_and_forms.erp_forms.rb +33 -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/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/20110816153456_add_knitkit_application.knitkit.rb +32 -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/20110828190913_create_desktop_app_dynamic_forms.erp_forms.rb +19 -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/20111118182910_setup_knitkit_capabilities.knitkit.rb +128 -0
- data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
- data/spec/dummy/db/data_migrations/20120127144444_create_website_role_types.knitkit.rb +14 -0
- data/spec/dummy/db/data_migrations/20120127150505_create_website_default_configuration.knitkit.rb +73 -0
- data/spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb +34 -0
- data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
- data/spec/dummy/db/data_migrations/20120316150424_add_is_template_to_default_website_config.knitkit.rb +17 -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/20120809020508_update_website_and_configuration.knitkit.rb +78 -0
- data/spec/dummy/db/data_migrations/20120824013449_create_ticket_form.erp_forms.rb +67 -0
- data/spec/dummy/db/data_migrations/20121026013449_update_ticket_form.erp_forms.rb +65 -0
- data/spec/dummy/db/data_migrations/20121026191738_update_contact_form.erp_forms.rb +27 -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/20121129185611_upgrade_website_role_iid.knitkit.rb +21 -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/20121219182151_base_erp_services.erp_base_erp_svcs.rb +461 -0
- data/spec/dummy/db/migrate/20121219182152_recreate_party_search_facts_table.erp_search.rb +40 -0
- data/spec/dummy/db/migrate/20121219182153_base_tech_services.erp_tech_svcs.rb +255 -0
- data/spec/dummy/db/migrate/20121219182154_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
- data/spec/dummy/db/migrate/20121219182155_base_app_framework.erp_app.rb +276 -0
- data/spec/dummy/db/migrate/20121219182156_dynamic_forms.erp_forms.rb +95 -0
- data/spec/dummy/db/migrate/20121219182157_create_tickets.erp_forms.rb +19 -0
- data/spec/dummy/db/migrate/20121219182158_upgrade_dynamic_forms_table.erp_forms.rb +32 -0
- data/spec/dummy/db/migrate/20121219182159_setup_knitkit.knitkit.rb +316 -0
- data/spec/dummy/db/migrate/20130107181410_create_groups.erp_tech_svcs.rb +19 -0
- data/spec/dummy/db/migrate/20130107181411_upgrade_security.erp_tech_svcs.rb +54 -0
- data/spec/dummy/db/migrate/20130107181412_upgrade_security2.erp_tech_svcs.rb +270 -0
- data/spec/dummy/db/schema.rb +1172 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/development.log +3 -0
- data/spec/dummy/log/spec.log +26839 -0
- data/spec/dummy/log/sunspot-solr-spec.log +24338 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +238 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/spec/index/segments.gen +0 -0
- data/spec/dummy/solr/data/spec/index/segments_av +0 -0
- data/spec/dummy/solr/data/spec/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/spec/spellchecker/segments_1 +0 -0
- data/spec/dummy/solr/pids/spec/sunspot-solr-spec.pid +1 -0
- data/spec/spec_helper.rb +19 -10
- metadata +171 -80
@@ -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
|