From 04c8a6bcf8ac3c1619442ebf2eca5fb4ba253be8 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 26 Sep 2015 17:14:42 +0200 Subject: [PATCH] Merged migrations. --- db/migrate/20120101000001_create_base.rb | 20 +++++ db/migrate/20130305065226_scheduler_create.rb | 61 --------------- db/migrate/20150223000001_update_overview2.rb | 34 --------- db/migrate/20150701000001_add_cleanup.rb | 33 --------- db/migrate/20150824000001_update_cleanup.rb | 29 -------- db/seeds.rb | 74 ++++++++++++++++++- 6 files changed, 93 insertions(+), 158 deletions(-) delete mode 100644 db/migrate/20130305065226_scheduler_create.rb delete mode 100644 db/migrate/20150223000001_update_overview2.rb delete mode 100644 db/migrate/20150701000001_add_cleanup.rb delete mode 100644 db/migrate/20150824000001_update_cleanup.rb diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index bb9851a1f..3e66918df 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -190,6 +190,7 @@ class CreateBase < ActiveRecord::Migration add_index :tokens, :user_id add_index :tokens, [:name, :action], unique: true add_index :tokens, :created_at + add_index :tokens, :persistent create_table :packages do |t| t.string :name, limit: 250, null: false @@ -396,6 +397,25 @@ class CreateBase < ActiveRecord::Migration t.timestamps end add_index :online_notifications, [:user_id] + add_index :online_notifications, [:seen] + add_index :online_notifications, [:created_at] + add_index :online_notifications, [:updated_at] + + create_table :schedulers do |t| + t.column :name, :string, limit: 250, null: false + t.column :method, :string, limit: 250, null: false + t.column :period, :integer, null: true + t.column :running, :integer, null: false, default: false + t.column :last_run, :timestamp, null: true + t.column :prio, :integer, null: false + t.column :pid, :string, limit: 250, null: true + t.column :note, :string, limit: 250, null: true + t.column :active, :boolean, null: false, default: false + t.column :updated_by_id, :integer, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :schedulers, [:name], unique: true create_table :delayed_jobs, force: true do |t| t.integer :priority, default: 0 # Allows some jobs to jump to the front of the queue diff --git a/db/migrate/20130305065226_scheduler_create.rb b/db/migrate/20130305065226_scheduler_create.rb deleted file mode 100644 index 790429680..000000000 --- a/db/migrate/20130305065226_scheduler_create.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'scheduler' -require 'setting' -class SchedulerCreate < ActiveRecord::Migration - def up - create_table :schedulers do |t| - t.column :name, :string, limit: 250, null: false - t.column :method, :string, limit: 250, null: false - t.column :period, :integer, null: true - t.column :running, :integer, null: false, default: false - t.column :last_run, :timestamp, null: true - t.column :prio, :integer, null: false - t.column :pid, :string, limit: 250, null: true - t.column :note, :string, limit: 250, null: true - t.column :active, :boolean, null: false, default: false - t.column :updated_by_id, :integer, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :schedulers, [:name], unique: true - Scheduler.create_or_update( - name: 'Import OTRS diff load', - method: 'Import::OTRS.diff_worker', - period: 60 * 3, - prio: 1, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - Scheduler.create_or_update( - name: 'Check Channels', - method: 'Channel.fetch', - period: 30, - prio: 1, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - Scheduler.create_or_update( - name: 'Generate Session data', - method: 'Sessions.jobs', - period: 60, - prio: 1, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - Scheduler.create_or_update( - name: 'Cleanup expired sessions', - method: 'SessionHelper.cleanup_expired', - period: 60 * 60 * 12, - prio: 2, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - end - - def down - drop_table :schedulers - end -end diff --git a/db/migrate/20150223000001_update_overview2.rb b/db/migrate/20150223000001_update_overview2.rb deleted file mode 100644 index 6ee9eca81..000000000 --- a/db/migrate/20150223000001_update_overview2.rb +++ /dev/null @@ -1,34 +0,0 @@ -class UpdateOverview2 < ActiveRecord::Migration - def up - - overview_role = Role.where( name: 'Agent' ).first - - return true if !overview_role - - UserInfo.current_user_id = 1 - Overview.create_or_update( - name: 'My assigned Tickets', - link: 'my_assigned', - prio: 1000, - role_id: overview_role.id, - condition: { - 'tickets.state_id' => [ 1, 2, 3, 7 ], - 'tickets.owner_id' => 'current_user.id', - }, - order: { - by: 'created_at', - direction: 'ASC', - }, - view: { - d: %w(title customer group created_at), - s: %w(title customer group created_at), - m: %w(number title customer group created_at), - view_mode_default: 's', - }, - ) - end - - def down - end - -end diff --git a/db/migrate/20150701000001_add_cleanup.rb b/db/migrate/20150701000001_add_cleanup.rb deleted file mode 100644 index 447a637a4..000000000 --- a/db/migrate/20150701000001_add_cleanup.rb +++ /dev/null @@ -1,33 +0,0 @@ -class AddCleanup < ActiveRecord::Migration - def up - - # delete old entries - Scheduler.create_or_update( - name: 'Delete old activity stream entries.', - method: 'ActivityStream.cleanup', - period: 1.day, - prio: 2, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - Scheduler.create_or_update( - name: 'Delete old online notification entries.', - method: 'OnlineNotification.cleanup', - period: 12.hours, - prio: 2, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - Scheduler.create_or_update( - name: 'Delete old entries.', - method: 'RecentView.cleanup', - period: 1.day, - prio: 2, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - end -end diff --git a/db/migrate/20150824000001_update_cleanup.rb b/db/migrate/20150824000001_update_cleanup.rb deleted file mode 100644 index 41cdcc190..000000000 --- a/db/migrate/20150824000001_update_cleanup.rb +++ /dev/null @@ -1,29 +0,0 @@ -class UpdateCleanup < ActiveRecord::Migration - def up - - # delete old entries - Scheduler.create_or_update( - name: 'Delete old online notification entries.', - method: 'OnlineNotification.cleanup', - period: 2.hours, - prio: 2, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - add_index :online_notifications, [:seen] - add_index :online_notifications, [:created_at] - add_index :online_notifications, [:updated_at] - - Scheduler.create_or_update( - name: 'Delete old token entries.', - method: 'Token.cleanup', - period: 30.days, - prio: 2, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - add_index :tokens, :persistent - end -end diff --git a/db/seeds.rb b/db/seeds.rb index 7da246fd5..e7e6d6c29 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1946,13 +1946,85 @@ Network::Item::Comment.create( body: 'Some comment....', ) -Scheduler.create_or_update( +Scheduler.create_if_not_exists( name: 'Process pending tickets', method: 'Ticket.process_pending', period: 60 * 15, prio: 1, active: true, ) +Scheduler.create_if_not_exists( + name: 'Import OTRS diff load', + method: 'Import::OTRS.diff_worker', + period: 60 * 3, + prio: 1, + active: true, + updated_by_id: 1, + created_by_id: 1, +) +Scheduler.create_if_not_exists( + name: 'Check Channels', + method: 'Channel.fetch', + period: 30, + prio: 1, + active: true, + updated_by_id: 1, + created_by_id: 1, +) +Scheduler.create_if_not_exists( + name: 'Generate Session data', + method: 'Sessions.jobs', + period: 60, + prio: 1, + active: true, + updated_by_id: 1, + created_by_id: 1, +) +Scheduler.create_if_not_exists( + name: 'Cleanup expired sessions', + method: 'SessionHelper.cleanup_expired', + period: 60 * 60 * 12, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, +) +Scheduler.create_if_not_exists( + name: 'Delete old activity stream entries.', + method: 'ActivityStream.cleanup', + period: 1.day, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, +) +Scheduler.create_if_not_exists( + name: 'Delete old entries.', + method: 'RecentView.cleanup', + period: 1.day, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, +) +Scheduler.create_or_update( + name: 'Delete old online notification entries.', + method: 'OnlineNotification.cleanup', + period: 2.hours, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, +) +Scheduler.create_or_update( + name: 'Delete old token entries.', + method: 'Token.cleanup', + period: 30.days, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, +) # install locales and translations Locale.create_if_not_exists(