From 949f414442a9a7c0f55290765085e11cb3142551 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 26 Sep 2015 17:41:21 +0200 Subject: [PATCH] Merged migrations. --- db/migrate/20120101000001_create_base.rb | 19 ++ .../20140831000001_create_object_manager.rb | 33 +++ db/migrate/20150206000002_create_address.rb | 70 ------ db/migrate/20150810000001_update_form.rb | 28 --- .../20150816000001_update_model_searchable.rb | 15 -- .../20150817000001_create_user_devices.rb | 27 --- db/migrate/20150830000002_update_settings2.rb | 50 ----- db/migrate/20150906000001_update_settings3.rb | 207 ------------------ 8 files changed, 52 insertions(+), 397 deletions(-) delete mode 100644 db/migrate/20150206000002_create_address.rb delete mode 100644 db/migrate/20150810000001_update_form.rb delete mode 100644 db/migrate/20150816000001_update_model_searchable.rb delete mode 100644 db/migrate/20150817000001_create_user_devices.rb delete mode 100644 db/migrate/20150830000002_update_settings2.rb delete mode 100644 db/migrate/20150906000001_update_settings3.rb diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 3e66918df..425d1bc49 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -417,6 +417,25 @@ class CreateBase < ActiveRecord::Migration end add_index :schedulers, [:name], unique: true + create_table :user_devices do |t| + t.references :user, null: false + t.string :name, limit: 250, null: false + t.string :os, limit: 150, null: true + t.string :browser, limit: 250, null: true + t.string :location, limit: 150, null: true + t.string :device_details, limit: 2500, null: true + t.string :location_details, limit: 2500, null: true + t.string :fingerprint, limit: 160, null: true + t.string :user_agent, limit: 250, null: true + t.string :ip, limit: 160, null: true + t.timestamps + end + add_index :user_devices, [:user_id] + add_index :user_devices, [:os, :browser, :location] + add_index :user_devices, [:fingerprint] + add_index :user_devices, [:updated_at] + add_index :user_devices, [:created_at] + create_table :delayed_jobs, force: true do |t| t.integer :priority, default: 0 # Allows some jobs to jump to the front of the queue t.integer :attempts, default: 0 # Provides for retries, but still fail eventually. diff --git a/db/migrate/20140831000001_create_object_manager.rb b/db/migrate/20140831000001_create_object_manager.rb index cddfa784a..ddde672f8 100644 --- a/db/migrate/20140831000001_create_object_manager.rb +++ b/db/migrate/20140831000001_create_object_manager.rb @@ -929,6 +929,39 @@ class CreateObjectManager < ActiveRecord::Migration updated_by_id: 1, ) + ObjectManager::Attribute.add( + object: 'User', + name: 'address', + display: 'Address', + data_type: 'textarea', + data_option: { + type: 'text', + maxlength: 500, + null: true, + item_class: 'formGroup--halfSize', + }, + editable: false, + active: true, + screens: { + signup: {}, + invite_agent: {}, + edit: { + '-all-' => { + null: true, + }, + }, + view: { + '-all-' => { + shown: true, + }, + }, + }, + pending_migration: false, + position: 1350, + created_by_id: 1, + updated_by_id: 1, + ) + ObjectManager::Attribute.add( object: 'User', name: 'password', diff --git a/db/migrate/20150206000002_create_address.rb b/db/migrate/20150206000002_create_address.rb deleted file mode 100644 index 96a34e330..000000000 --- a/db/migrate/20150206000002_create_address.rb +++ /dev/null @@ -1,70 +0,0 @@ -class CreateAddress < ActiveRecord::Migration - def up - add_column :users, :address, :string, limit: 500, null: true - - User.all.each {|user| - address = '' - if user.street && !user.street.empty? - address += "#{user.street}\n" - end - if user.zip && !user.zip.empty? - address += "#{user.zip} " - end - if user.city && !user.city.empty? - address += "#{user.city}" - end - if !address.empty? - user.address = address - user.save - end - } - - %w(street zip city department).each {|attribute_name| - attribute = ObjectManager::Attribute.get( - object: 'User', - name: attribute_name, - ) - if attribute - attribute.active = false - attribute.save - end - } - - ObjectManager::Attribute.add( - object: 'User', - name: 'address', - display: 'Address', - data_type: 'textarea', - data_option: { - type: 'text', - maxlength: 500, - null: true, - item_class: 'formGroup--halfSize', - }, - editable: false, - active: true, - screens: { - signup: {}, - invite_agent: {}, - edit: { - '-all-' => { - null: true, - }, - }, - view: { - '-all-' => { - shown: true, - }, - }, - }, - pending_migration: false, - position: 1350, - created_by_id: 1, - updated_by_id: 1, - ) - - end - - def down - end -end diff --git a/db/migrate/20150810000001_update_form.rb b/db/migrate/20150810000001_update_form.rb deleted file mode 100644 index 11d9d822e..000000000 --- a/db/migrate/20150810000001_update_form.rb +++ /dev/null @@ -1,28 +0,0 @@ -class UpdateForm < ActiveRecord::Migration - def up - - Setting.create_if_not_exists( - title: 'Enable Ticket creation', - name: 'form_ticket_create', - area: 'Form::Base', - description: 'Defines if ticket can get created via web form.', - options: { - form: [ - { - display: '', - null: true, - name: 'form_ticket_create', - tag: 'boolean', - options: { - true => 'yes', - false => 'no', - }, - }, - ], - }, - state: false, - frontend: false, - ) - - end -end diff --git a/db/migrate/20150816000001_update_model_searchable.rb b/db/migrate/20150816000001_update_model_searchable.rb deleted file mode 100644 index 72db5ad58..000000000 --- a/db/migrate/20150816000001_update_model_searchable.rb +++ /dev/null @@ -1,15 +0,0 @@ -class UpdateModelSearchable < ActiveRecord::Migration - def up - - Setting.create_if_not_exists( - title: 'Define searchable models.', - name: 'models_searchable', - area: 'Models::Base', - description: 'Define the models which can be searched for.', - options: {}, - state: [], - frontend: false, - ) - - end -end diff --git a/db/migrate/20150817000001_create_user_devices.rb b/db/migrate/20150817000001_create_user_devices.rb deleted file mode 100644 index 534a7c2c3..000000000 --- a/db/migrate/20150817000001_create_user_devices.rb +++ /dev/null @@ -1,27 +0,0 @@ - -class CreateUserDevices < ActiveRecord::Migration - def up - create_table :user_devices do |t| - t.references :user, null: false - t.string :name, limit: 250, null: false - t.string :os, limit: 150, null: true - t.string :browser, limit: 250, null: true - t.string :location, limit: 150, null: true - t.string :device_details, limit: 2500, null: true - t.string :location_details, limit: 2500, null: true - t.string :fingerprint, limit: 160, null: true - t.string :user_agent, limit: 250, null: true - t.string :ip, limit: 160, null: true - t.timestamps - end - add_index :user_devices, [:user_id] - add_index :user_devices, [:os, :browser, :location] - add_index :user_devices, [:fingerprint] - add_index :user_devices, [:updated_at] - add_index :user_devices, [:created_at] - end - - def down - drop_table :user_devices - end -end diff --git a/db/migrate/20150830000002_update_settings2.rb b/db/migrate/20150830000002_update_settings2.rb deleted file mode 100644 index a6d203115..000000000 --- a/db/migrate/20150830000002_update_settings2.rb +++ /dev/null @@ -1,50 +0,0 @@ -class UpdateSettings2 < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Additional follow up detection', - name: 'postmaster_follow_up_search_in', - area: 'Email::Base', - description: 'In default the follow up check is done via the subject of an email. With this setting you can add more fields where the follow up ckeck is executed. "References" - Executes follow up check on In-Reply-To or References headers for mails. "Body" - Executes follow up check in mail body. "Attachment" - Executes follow up check in mail attachments.', - options: { - form: [ - { - display: '', - null: true, - name: 'postmaster_follow_up_search_in', - tag: 'checkbox', - options: { - 'references' => 'References', - 'body' => 'Body', - 'attachment' => 'Attachment', - }, - }, - ], - }, - state: [], - frontend: false - ) - Setting.create_or_update( - title: 'Ticket Hook Position', - name: 'ticket_hook_position', - area: 'Ticket::Base', - description: 'The format of the subject. "Left" means "[Ticket#12345] Some Subject", "Right" means "Some Subject [Ticket#12345]", "None" means "Some Subject" and no ticket number. In the last case you should enable "postmaster_follow_up_search_in" to recognize followups based on email headers and/or body.', - options: { - form: [ - { - display: '', - null: true, - name: 'ticket_hook_position', - tag: 'select', - options: { - 'left' => 'Left', - 'right' => 'Right', - 'none' => 'None', - }, - }, - ], - }, - state: 'right', - frontend: false - ) - end -end diff --git a/db/migrate/20150906000001_update_settings3.rb b/db/migrate/20150906000001_update_settings3.rb deleted file mode 100644 index 1724310d2..000000000 --- a/db/migrate/20150906000001_update_settings3.rb +++ /dev/null @@ -1,207 +0,0 @@ -class UpdateSettings3 < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Maximal failed logins', - name: 'password_max_login_failed', - area: 'Security::Password', - description: 'Maximal failed logins after account is inactive.', - options: { - form: [ - { - display: '', - null: true, - name: 'password_max_login_failed', - tag: 'select', - options: { - 4 => ' 4', - 5 => ' 5', - 6 => ' 6', - 7 => ' 7', - 8 => ' 8', - 9 => ' 9', - 10 => '10', - 11 => '11', - 13 => '13', - 14 => '14', - 15 => '15', - 16 => '16', - 17 => '17', - 18 => '18', - 19 => '19', - 20 => '20', - }, - }, - ], - }, - state: 10, - frontend: true - ) - Setting.create_or_update( - title: 'Max. Email Size', - name: 'postmaster_max_size', - area: 'Email::Base', - description: 'Maximal size in MB of emails.', - options: { - form: [ - { - display: '', - null: true, - name: 'postmaster_max_size', - tag: 'select', - options: { - 1 => ' 1', - 2 => ' 2', - 3 => ' 3', - 4 => ' 4', - 5 => ' 5', - 6 => ' 6', - 7 => ' 7', - 8 => ' 8', - 9 => ' 9', - 10 => ' 10', - 15 => ' 15', - 20 => ' 20', - 25 => ' 25', - 30 => ' 30', - 35 => ' 35', - 40 => ' 40', - 45 => ' 45', - 50 => ' 50', - 60 => ' 60', - 70 => ' 70', - 80 => ' 80', - 90 => ' 90', - 100 => '100', - 125 => '125', - 150 => '150', - }, - }, - ], - }, - state: 10, - preferences: { online_service_disable: true }, - frontend: false - ) - Setting.create_or_update( - title: 'Ticket Number Increment', - name: 'ticket_number_increment', - area: 'Ticket::Number', - description: '-', - options: { - form: [ - { - display: 'Checksum', - null: true, - name: 'checksum', - tag: 'boolean', - options: { - true => 'yes', - false => 'no', - }, - }, - { - display: 'Min. size of number', - null: true, - name: 'min_size', - tag: 'select', - options: { - 1 => ' 1', - 2 => ' 2', - 3 => ' 3', - 4 => ' 4', - 5 => ' 5', - 6 => ' 6', - 7 => ' 7', - 8 => ' 8', - 9 => ' 9', - 10 => '10', - 11 => '11', - 12 => '12', - 13 => '13', - 14 => '14', - 15 => '15', - 16 => '16', - 17 => '17', - 18 => '18', - 19 => '19', - 20 => '20', - }, - }, - ], - }, - state: { - checksum: false, - min_size: 5, - }, - frontend: false - ) - Setting.create_or_update( - title: 'Minimal size', - name: 'password_min_size', - area: 'Security::Password', - description: 'Password need to have at least minimal size of characters.', - options: { - form: [ - { - display: '', - null: true, - name: 'password_min_size', - tag: 'select', - options: { - 4 => ' 4', - 5 => ' 5', - 6 => ' 6', - 7 => ' 7', - 8 => ' 8', - 9 => ' 9', - 10 => '10', - 11 => '11', - 12 => '12', - 13 => '13', - 14 => '14', - 15 => '15', - 16 => '16', - 17 => '17', - 18 => '18', - 19 => '19', - 20 => '20', - }, - }, - ], - }, - state: 6, - frontend: true - ) - - options = {} - (10..99).each {|item| - options[item] = item - } - system_id = rand(10..99) - current = Setting.find_by(name: 'system_id') - if current - system_id = Setting.get('system_id') - end - Setting.create_or_update( - title: 'SystemID', - name: 'system_id', - area: 'System::Base', - description: 'Defines the system identifier. Every ticket number contains this ID. This ensures that only tickets which belong to your system will be processed as follow-ups (useful when communicating between two instances of Zammad).', - options: { - form: [ - { - display: '', - null: true, - name: 'system_id', - tag: 'select', - options: options, - }, - ], - }, - state: system_id, - preferences: { online_service_disable: true }, - frontend: true - ) - - end -end