From 9babb669b4b360e1791d22f38f213f6afe9cde7d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 03:08:01 +0200 Subject: [PATCH] Merged some migrations. --- db/migrate/20120101000001_create_base.rb | 35 ++++++ db/migrate/20120101000010_create_ticket.rb | 59 +++++++++++ db/migrate/20120101000030_create_storage.rb | 44 -------- db/migrate/20120101000090_create_template.rb | 26 ----- ...20120101000100_postmaster_filter_create.rb | 19 ---- .../20120101000110_text_module_create.rb | 30 ------ db/migrate/20140128000001_add_search_index.rb | 59 ----------- db/migrate/20141119000001_update_setting2.rb | 34 ------ db/migrate/20141126000001_create_avatar.rb | 2 +- .../20141217000001_update_object_manager2.rb | 39 ++++++- .../20141227000001_update_ticket_article.rb | 8 -- db/migrate/20141231000001_add_develop_mode.rb | 16 --- db/migrate/20150206000001_create_vip.rb | 47 -------- .../20150208000001_update_object_manager3.rb | 100 ------------------ .../20150215082745_rename_avatar_typo.rb | 9 -- .../20150322000001_update_geo_ip_config.rb | 30 ------ db/seeds.rb | 49 +++++++++ 17 files changed, 182 insertions(+), 424 deletions(-) delete mode 100644 db/migrate/20120101000030_create_storage.rb delete mode 100644 db/migrate/20120101000090_create_template.rb delete mode 100644 db/migrate/20120101000100_postmaster_filter_create.rb delete mode 100644 db/migrate/20120101000110_text_module_create.rb delete mode 100644 db/migrate/20140128000001_add_search_index.rb delete mode 100644 db/migrate/20141119000001_update_setting2.rb delete mode 100644 db/migrate/20141227000001_update_ticket_article.rb delete mode 100644 db/migrate/20141231000001_add_develop_mode.rb delete mode 100644 db/migrate/20150206000001_create_vip.rb delete mode 100644 db/migrate/20150208000001_update_object_manager3.rb delete mode 100644 db/migrate/20150215082745_rename_avatar_typo.rb delete mode 100644 db/migrate/20150322000001_update_geo_ip_config.rb diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 2bc455343..45df4af0b 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -27,6 +27,7 @@ class CreateBase < ActiveRecord::Migration t.column :zip, :string, limit: 100, null: true, default: '' t.column :city, :string, limit: 100, null: true, default: '' t.column :country, :string, limit: 100, null: true, default: '' + t.column :vip, :boolean, default: false t.column :verified, :boolean, null: false, default: false t.column :active, :boolean, null: false, default: true t.column :note, :string, limit: 250, null: true, default: '' @@ -316,5 +317,39 @@ class CreateBase < ActiveRecord::Migration add_index :settings, [:area] add_index :settings, [:frontend] + create_table :stores do |t| + t.references :store_object, null: false + t.references :store_file, null: false + t.column :o_id, :integer, limit: 8, null: false + t.column :preferences, :string, limit: 2500, null: true + t.column :size, :string, limit: 50, null: true + t.column :filename, :string, limit: 250, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :stores, [:store_object_id, :o_id] + + create_table :store_objects do |t| + t.column :name, :string, limit: 250, null: false + t.column :note, :string, limit: 250, null: true + t.timestamps + end + add_index :store_objects, [:name], unique: true + + create_table :store_files do |t| + t.column :sha, :string, limit: 128, null: false + t.column :provider, :string, limit: 20, null: true + t.timestamps + end + add_index :store_files, [:sha], unique: true + add_index :store_files, [:provider] + + create_table :store_provider_dbs do |t| + t.column :sha, :string, limit: 128, null: false + t.column :data, :binary, limit: 200.megabytes, null: true + t.timestamps + end + add_index :store_provider_dbs, [:sha], unique: true + end end diff --git a/db/migrate/20120101000010_create_ticket.rb b/db/migrate/20120101000010_create_ticket.rb index ba38be820..86053b439 100644 --- a/db/migrate/20120101000010_create_ticket.rb +++ b/db/migrate/20120101000010_create_ticket.rb @@ -145,6 +145,7 @@ class CreateTicket < ActiveRecord::Migration t.column :message_id, :string, limit: 3000, null: true t.column :message_id_md5, :string, limit: 32, null: true t.column :in_reply_to, :string, limit: 3000, null: true + t.column :content_type, :string, limit: 20, null: false, default: 'text/plain' t.column :references, :string, limit: 3200, null: true t.column :body, :text, limit: 4.megabytes + 1 t.column :internal, :boolean, null: false, default: false @@ -248,9 +249,67 @@ class CreateTicket < ActiveRecord::Migration t.timestamps end add_index :links, [:link_object_source_id, :link_object_source_value, :link_object_target_id, :link_object_target_value, :link_type_id], unique: true, name: 'links_uniq_total' + + create_table :postmaster_filters do |t| + t.column :name, :string, limit: 250, null: false + t.column :channel, :string, limit: 250, null: false + t.column :match, :string, limit: 5000, null: false + t.column :perform, :string, limit: 5000, null: false + t.column :active, :boolean, null: false, default: true + t.column :note, :string, limit: 250, null: true + t.column :updated_by_id, :integer, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :postmaster_filters, [:channel] + + create_table :text_modules do |t| + t.references :user, null: true + t.column :name, :string, limit: 250, null: false + t.column :keywords, :string, limit: 500, null: true + t.column :content, :string, limit: 5000, null: false + t.column :note, :string, limit: 250, null: true + t.column :active, :boolean, null: false, default: true + t.column :updated_by_id, :integer, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :text_modules, [:user_id] + add_index :text_modules, [:name] + + create_table :text_modules_groups, id: false do |t| + t.integer :text_module_id + t.integer :group_id + end + add_index :text_modules_groups, [:text_module_id] + add_index :text_modules_groups, [:group_id] + + create_table :templates do |t| + t.references :user, null: true + t.column :name, :string, limit: 250, null: false + t.column :options, :string, limit: 2500, null: false + t.column :updated_by_id, :integer, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :templates, [:user_id] + add_index :templates, [:name] + + create_table :templates_groups, id: false do |t| + t.integer :template_id + t.integer :group_id + end + add_index :templates_groups, [:template_id] + add_index :templates_groups, [:group_id] + end def self.down + drop_table :templates_groups + drop_table :templates + drop_table :text_modules_groups + drop_table :text_modules + drop_table :postmaster_filters drop_table :notifications drop_table :triggers drop_table :links diff --git a/db/migrate/20120101000030_create_storage.rb b/db/migrate/20120101000030_create_storage.rb deleted file mode 100644 index 8812680e0..000000000 --- a/db/migrate/20120101000030_create_storage.rb +++ /dev/null @@ -1,44 +0,0 @@ -class CreateStorage < ActiveRecord::Migration - def up - create_table :stores do |t| - t.references :store_object, null: false - t.references :store_file, null: false - t.column :o_id, :integer, limit: 8, null: false - t.column :preferences, :string, limit: 2500, null: true - t.column :size, :string, limit: 50, null: true - t.column :filename, :string, limit: 250, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :stores, [:store_object_id, :o_id] - - create_table :store_objects do |t| - t.column :name, :string, limit: 250, null: false - t.column :note, :string, limit: 250, null: true - t.timestamps - end - add_index :store_objects, [:name], unique: true - - create_table :store_files do |t| - t.column :sha, :string, limit: 128, null: false - t.column :provider, :string, limit: 20, null: true - t.timestamps - end - add_index :store_files, [:sha], unique: true - add_index :store_files, [:provider] - - create_table :store_provider_dbs do |t| - t.column :sha, :string, limit: 128, null: false - t.column :data, :binary, limit: 200.megabytes, null: true - t.timestamps - end - add_index :store_provider_dbs, [:sha], unique: true - - end - - def down - drop_table :stores - drop_table :store_objects - drop_table :store_files - end -end diff --git a/db/migrate/20120101000090_create_template.rb b/db/migrate/20120101000090_create_template.rb deleted file mode 100644 index 52e8f9ffc..000000000 --- a/db/migrate/20120101000090_create_template.rb +++ /dev/null @@ -1,26 +0,0 @@ -class CreateTemplate < ActiveRecord::Migration - def up - create_table :templates do |t| - t.references :user, null: true - t.column :name, :string, limit: 250, null: false - t.column :options, :string, limit: 2500, null: false - t.column :updated_by_id, :integer, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :templates, [:user_id] - add_index :templates, [:name] - - create_table :templates_groups, id: false do |t| - t.integer :template_id - t.integer :group_id - end - add_index :templates_groups, [:template_id] - add_index :templates_groups, [:group_id] - end - - def down - drop_table :templates_groups - drop_table :templates - end -end diff --git a/db/migrate/20120101000100_postmaster_filter_create.rb b/db/migrate/20120101000100_postmaster_filter_create.rb deleted file mode 100644 index 7f0702643..000000000 --- a/db/migrate/20120101000100_postmaster_filter_create.rb +++ /dev/null @@ -1,19 +0,0 @@ -class PostmasterFilterCreate < ActiveRecord::Migration - def up - create_table :postmaster_filters do |t| - t.column :name, :string, limit: 250, null: false - t.column :channel, :string, limit: 250, null: false - t.column :match, :string, limit: 5000, null: false - t.column :perform, :string, limit: 5000, null: false - t.column :active, :boolean, null: false, default: true - t.column :note, :string, limit: 250, null: true - t.column :updated_by_id, :integer, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :postmaster_filters, [:channel] - end - - def down - end -end diff --git a/db/migrate/20120101000110_text_module_create.rb b/db/migrate/20120101000110_text_module_create.rb deleted file mode 100644 index d8c995aee..000000000 --- a/db/migrate/20120101000110_text_module_create.rb +++ /dev/null @@ -1,30 +0,0 @@ -class TextModuleCreate < ActiveRecord::Migration - def up - create_table :text_modules do |t| - t.references :user, null: true - t.column :name, :string, limit: 250, null: false - t.column :keywords, :string, limit: 500, null: true - t.column :content, :string, limit: 5000, null: false - t.column :note, :string, limit: 250, null: true - t.column :active, :boolean, null: false, default: true - t.column :updated_by_id, :integer, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :text_modules, [:user_id] - add_index :text_modules, [:name] - - create_table :text_modules_groups, id: false do |t| - t.integer :text_module_id - t.integer :group_id - end - add_index :text_modules_groups, [:text_module_id] - add_index :text_modules_groups, [:group_id] - end - - def down - drop_table :text_modules_groups - drop_table :text_modules - end - -end diff --git a/db/migrate/20140128000001_add_search_index.rb b/db/migrate/20140128000001_add_search_index.rb deleted file mode 100644 index 114d3dbaf..000000000 --- a/db/migrate/20140128000001_add_search_index.rb +++ /dev/null @@ -1,59 +0,0 @@ -class AddSearchIndex < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Elasticsearch Endpoint URL', - name: 'es_url', - area: 'SearchIndex::Elasticsearch', - description: 'Define endpoint of Elastic Search.', - state: '', - frontend: false - ) - Setting.create_or_update( - title: 'Elasticsearch Endpoint User', - name: 'es_user', - area: 'SearchIndex::Elasticsearch', - description: 'Define http basic auth user of Elasticsearch.', - state: '', - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Endpoint Password', - name: 'es_password', - area: 'SearchIndex::Elasticsearch', - description: 'Define http basic auth password of Elasticsearch.', - state: '', - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Endpoint Index', - name: 'es_index', - area: 'SearchIndex::Elasticsearch', - description: 'Define Elasticsearch index name.', - state: 'zammad', - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Attachment Extentions', - name: 'es_attachment_ignore', - area: 'SearchIndex::Elasticsearch', - description: 'Define attachment extentions which are ignored for Elasticsearch.', - state: [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ], - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Attachment Size', - name: 'es_attachment_max_size_in_mb', - area: 'SearchIndex::Elasticsearch', - description: 'Define max. attachment size for Elasticsearch.', - state: 50, - frontend: false - ) - - Ticket.search_index_reload - User.search_index_reload - Organization.search_index_reload - end - - def down - end -end diff --git a/db/migrate/20141119000001_update_setting2.rb b/db/migrate/20141119000001_update_setting2.rb deleted file mode 100644 index 021863b75..000000000 --- a/db/migrate/20141119000001_update_setting2.rb +++ /dev/null @@ -1,34 +0,0 @@ -class UpdateSetting2 < ActiveRecord::Migration - def up - Setting.create_if_not_exists( - title: 'Logo', - name: 'product_logo', - area: 'System::CI', - description: 'Defines the logo of the application, shown in the web interface.', - options: { - form: [ - { - display: '', - null: false, - name: 'product_logo', - tag: 'input', - }, - ], - }, - state: 'logo.svg', - frontend: true - ) - Setting.create_if_not_exists( - title: 'Online Service', - name: 'system_online_service', - area: 'Core', - description: 'Defines if application is used as online service.', - options: {}, - state: false, - frontend: true - ) - end - - def down - end -end diff --git a/db/migrate/20141126000001_create_avatar.rb b/db/migrate/20141126000001_create_avatar.rb index adb15706a..3b267ad98 100644 --- a/db/migrate/20141126000001_create_avatar.rb +++ b/db/migrate/20141126000001_create_avatar.rb @@ -5,7 +5,7 @@ class CreateAvatar < ActiveRecord::Migration t.column :object_lookup_id, :integer, null: false t.column :default, :boolean, null: false, default: false t.column :deletable, :boolean, null: false, default: true - t.column :inital, :boolean, null: false, default: false + t.column :initial, :boolean, null: false, default: false t.column :store_full_id, :integer, null: true t.column :store_resize_id, :integer, null: true t.column :store_hash, :string, limit: 32, null: true diff --git a/db/migrate/20141217000001_update_object_manager2.rb b/db/migrate/20141217000001_update_object_manager2.rb index 69e5058a4..a78bc14a5 100644 --- a/db/migrate/20141217000001_update_object_manager2.rb +++ b/db/migrate/20141217000001_update_object_manager2.rb @@ -487,6 +487,44 @@ class UpdateObjectManager2 < ActiveRecord::Migration updated_by_id: 1, ) + ObjectManager::Attribute.add( + object: 'User', + name: 'vip', + display: 'VIP', + data_type: 'boolean', + data_option: { + null: true, + default: false, + item_class: 'formGroup--halfSize', + options: { + false: 'no', + true: 'yes', + }, + translate: true, + }, + editable: false, + active: true, + screens: { + edit: { + Admin: { + null: true, + }, + Agent: { + null: true, + }, + }, + view: { + '-all-' => { + shown: false, + }, + }, + }, + pending_migration: false, + position: 1490, + created_by_id: 1, + updated_by_id: 1, + ) + ObjectManager::Attribute.add( object: 'User', name: 'note', @@ -594,7 +632,6 @@ class UpdateObjectManager2 < ActiveRecord::Migration display: 'Active', data_type: 'active', data_option: { - null: true, default: true, }, editable: false, diff --git a/db/migrate/20141227000001_update_ticket_article.rb b/db/migrate/20141227000001_update_ticket_article.rb deleted file mode 100644 index 35e60c89c..000000000 --- a/db/migrate/20141227000001_update_ticket_article.rb +++ /dev/null @@ -1,8 +0,0 @@ -class UpdateTicketArticle < ActiveRecord::Migration - def up - add_column :ticket_articles, :content_type, :string, limit: 20, null: false, default: 'text/plain' - end - - def down - end -end diff --git a/db/migrate/20141231000001_add_develop_mode.rb b/db/migrate/20141231000001_add_develop_mode.rb deleted file mode 100644 index 36309fba6..000000000 --- a/db/migrate/20141231000001_add_develop_mode.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddDevelopMode < ActiveRecord::Migration - def up - Setting.create_if_not_exists( - title: 'Develop System', - name: 'developer_mode', - area: 'Core::Develop', - description: 'Defines if application is in developer mode (useful for developer, all users have the same password, password reset will work without email delivery).', - options: {}, - state: false, - frontend: true - ) - end - - def down - end -end diff --git a/db/migrate/20150206000001_create_vip.rb b/db/migrate/20150206000001_create_vip.rb deleted file mode 100644 index fd48bee4b..000000000 --- a/db/migrate/20150206000001_create_vip.rb +++ /dev/null @@ -1,47 +0,0 @@ -class CreateVip < ActiveRecord::Migration - def up - add_column :users, :vip, :boolean, default: false - - ObjectManager::Attribute.add( - object: 'User', - name: 'vip', - display: 'VIP', - data_type: 'boolean', - data_option: { - null: true, - default: false, - item_class: 'formGroup--halfSize', - options: { - false: 'no', - true: 'yes', - }, - translate: true, - }, - editable: false, - active: true, - screens: { - edit: { - Admin: { - null: true, - }, - Agent: { - null: true, - }, - }, - view: { - '-all-' => { - shown: false, - }, - }, - }, - pending_migration: false, - position: 1490, - created_by_id: 1, - updated_by_id: 1, - ) - - end - - def down - end -end diff --git a/db/migrate/20150208000001_update_object_manager3.rb b/db/migrate/20150208000001_update_object_manager3.rb deleted file mode 100644 index 6ff3b8b88..000000000 --- a/db/migrate/20150208000001_update_object_manager3.rb +++ /dev/null @@ -1,100 +0,0 @@ -class UpdateObjectManager3 < ActiveRecord::Migration - def up - - ObjectManager::Attribute.add( - object: 'User', - name: 'active', - display: 'Active', - data_type: 'active', - data_option: { - default: true, - }, - editable: false, - active: true, - screens: { - signup: {}, - invite_agent: {}, - edit: { - Admin: { - null: false, - }, - }, - view: { - '-all-' => { - shown: false, - }, - }, - }, - pending_migration: false, - position: 1800, - created_by_id: 1, - updated_by_id: 1, - ) - - ObjectManager::Attribute.add( - object: 'Organization', - name: 'active', - display: 'Active', - data_type: 'active', - data_option: { - default: true, - }, - editable: false, - active: true, - screens: { - edit: { - Admin: { - null: false, - }, - }, - view: { - '-all-' => { - shown: false, - }, - }, - }, - pending_migration: false, - position: 1800, - created_by_id: 1, - updated_by_id: 1, - ) - - ObjectManager::Attribute.add( - object: 'User', - name: 'password', - display: 'Password', - data_type: 'input', - data_option: { - type: 'password', - maxlength: 100, - null: true, - autocomplete: 'off', - item_class: 'formGroup--halfSize', - }, - editable: false, - active: true, - screens: { - signup: { - '-all-' => { - null: false, - }, - }, - invite_agent: {}, - edit: { - Admin: { - null: true, - }, - }, - view: {} - }, - pending_migration: false, - position: 1400, - created_by_id: 1, - updated_by_id: 1, - ) - - end - - def down - end -end diff --git a/db/migrate/20150215082745_rename_avatar_typo.rb b/db/migrate/20150215082745_rename_avatar_typo.rb deleted file mode 100644 index d0f9abcc5..000000000 --- a/db/migrate/20150215082745_rename_avatar_typo.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RenameAvatarTypo < ActiveRecord::Migration - def up - rename_column :avatars, :inital, :initial - end - - def down - rename_column :avatars, :initial, :inital - end -end diff --git a/db/migrate/20150322000001_update_geo_ip_config.rb b/db/migrate/20150322000001_update_geo_ip_config.rb deleted file mode 100644 index b16528a3f..000000000 --- a/db/migrate/20150322000001_update_geo_ip_config.rb +++ /dev/null @@ -1,30 +0,0 @@ -class UpdateGeoIpConfig < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Geo IP Backend', - name: 'geo_ip_backend', - area: 'System::Geo', - description: 'Defines the backend for geo ip lookups.', - options: { - form: [ - { - display: '', - null: true, - name: 'geo_ip_backend', - tag: 'select', - options: { - '' => '-', - 'GeoIp::ZammadGeoIp' => 'Zammad GeoIP Service', - }, - }, - ], - }, - state: 'GeoIp::ZammadGeoIp', - frontend: false - ) - end - - def down - end - -end diff --git a/db/seeds.rb b/db/seeds.rb index 67402ce53..c8294811b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1130,6 +1130,55 @@ Setting.create_if_not_exists( frontend: true ) +Setting.create_if_not_exists( + title: 'Elasticsearch Endpoint URL', + name: 'es_url', + area: 'SearchIndex::Elasticsearch', + description: 'Define endpoint of Elastic Search.', + state: '', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elasticsearch Endpoint User', + name: 'es_user', + area: 'SearchIndex::Elasticsearch', + description: 'Define http basic auth user of Elasticsearch.', + state: '', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Endpoint Password', + name: 'es_password', + area: 'SearchIndex::Elasticsearch', + description: 'Define http basic auth password of Elasticsearch.', + state: '', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Endpoint Index', + name: 'es_index', + area: 'SearchIndex::Elasticsearch', + description: 'Define Elasticsearch index name.', + state: 'zammad', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Attachment Extentions', + name: 'es_attachment_ignore', + area: 'SearchIndex::Elasticsearch', + description: 'Define attachment extentions which are ignored for Elasticsearch.', + state: [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ], + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Attachment Size', + name: 'es_attachment_max_size_in_mb', + area: 'SearchIndex::Elasticsearch', + description: 'Define max. attachment size for Elasticsearch.', + state: 50, + frontend: false +) + Setting.create_if_not_exists( title: 'Import Mode', name: 'import_mode',