Browse Source

Cleanup of migrations.

Martin Edenhofer 8 years ago
parent
commit
ad85f98886

+ 79 - 0
db/migrate/20120101000001_create_base.rb

@@ -518,5 +518,84 @@ class CreateBase < ActiveRecord::Migration
 
     add_index :delayed_jobs, [:priority, :run_at], name: 'delayed_jobs_priority'
 
+    create_table :external_syncs do |t|
+      t.string  :source,                 limit: 100,  null: false
+      t.string  :source_id,              limit: 200,  null: false
+      t.string  :object,                 limit: 100,  null: false
+      t.integer :o_id,                                null: false
+      t.text    :last_payload,           limit: 500.kilobytes + 1, null: true
+      t.timestamps limit: 3, null: false
+    end
+    add_index :external_syncs, [:source, :source_id], unique: true
+    add_index :external_syncs, [:source, :source_id, :object, :o_id], name: 'index_external_syncs_on_source_and_source_id_and_object_o_id'
+    add_index :external_syncs, [:object, :o_id]
+
+    create_table :cti_logs do |t|
+      t.string  :direction,              limit: 20,   null: false
+      t.string  :state,                  limit: 20,   null: false
+      t.string  :from,                   limit: 100,  null: false
+      t.string  :from_comment,           limit: 250,  null: true
+      t.string  :to,                     limit: 100,  null: false
+      t.string  :to_comment,             limit: 250,  null: true
+      t.string  :call_id,                limit: 250,  null: false
+      t.string  :comment,                limit: 500,  null: true
+      t.timestamp :start,                limit: 3,    null: true
+      t.timestamp :end,                  limit: 3,    null: true
+      t.boolean   :done,                              null: false, default: true
+      t.text :preferences,            limit: 500.kilobytes + 1, null: true
+      t.timestamps limit: 3, null: false
+    end
+    add_index :cti_logs, [:call_id], unique: true
+    add_index :cti_logs, [:direction]
+    add_index :cti_logs, [:from]
+
+    create_table :cti_caller_ids do |t|
+      t.string  :caller_id,              limit: 100, null: false
+      t.string  :comment,                limit: 500, null: true
+      t.string  :level,                  limit: 100, null: false
+      t.string  :object,                 limit: 100, null: false
+      t.integer :o_id,                               null: false
+      t.integer :user_id,                            null: true
+      t.text    :preferences,            limit: 500.kilobytes + 1, null: true
+      t.timestamps limit: 3, null: false
+    end
+    add_index :cti_caller_ids, [:caller_id]
+    add_index :cti_caller_ids, [:caller_id, :level]
+    add_index :cti_caller_ids, [:caller_id, :user_id]
+    add_index :cti_caller_ids, [:object, :o_id]
+
+    create_table :stats_stores do |t|
+      t.references :stats_store_object,             null: false
+      t.integer :o_id,                              null: false
+      t.string  :key,                   limit: 250, null: true
+      t.integer :related_o_id,                      null: true
+      t.integer :related_stats_store_object_id,     null: true
+      t.string  :data,                 limit: 2500, null: true
+      t.integer :created_by_id,                     null: false
+      t.timestamps limit: 3, null: false
+    end
+    add_index :stats_stores, [:o_id]
+    add_index :stats_stores, [:key]
+    add_index :stats_stores, [:stats_store_object_id]
+    add_index :stats_stores, [:created_by_id]
+    add_index :stats_stores, [:created_at]
+
+    create_table :http_logs do |t|
+      t.column :direction,            :string, limit: 20,    null: false
+      t.column :facility,             :string, limit: 100,   null: false
+      t.column :method,               :string, limit: 100,   null: false
+      t.column :url,                  :string, limit: 255,   null: false
+      t.column :status,               :string, limit: 20,    null: true
+      t.column :ip,                   :string, limit: 50,    null: true
+      t.column :request,              :string, limit: 10_000, null: false
+      t.column :response,             :string, limit: 10_000, null: false
+      t.column :updated_by_id,        :integer,              null: true
+      t.column :created_by_id,        :integer,              null: true
+      t.timestamps limit: 3, null: false
+    end
+    add_index :http_logs, [:facility]
+    add_index :http_logs, [:created_by_id]
+    add_index :http_logs, [:created_at]
+
   end
 end

+ 34 - 1
db/migrate/20120101000010_create_ticket.rb

@@ -231,7 +231,7 @@ class CreateTicket < ActiveRecord::Migration
 
     create_table :jobs do |t|
       t.column :name,                 :string,  limit: 250,  null: false
-      t.column :timeplan,             :string,  limit: 500,  null: false
+      t.column :timeplan,             :string,  limit: 1000, null: false
       t.column :condition,            :string,  limit: 2500, null: false
       t.column :perform,              :string,  limit: 2500, null: false
       t.column :disable_notification, :boolean,              null: false, default: true
@@ -445,9 +445,42 @@ class CreateTicket < ActiveRecord::Migration
     end
     add_index :report_profiles, [:name], unique: true
 
+    create_table :karma_users do |t|
+      t.integer :user_id,                           null: false
+      t.integer :score,                             null: false
+      t.string  :level,               limit: 200,   null: false
+      t.timestamps limit: 3, null: false
+    end
+    add_index :karma_users, [:user_id], unique: true
+
+    create_table :karma_activities do |t|
+      t.string  :name,                limit: 200,    null: false
+      t.string  :description,         limit: 200,    null: false
+      t.integer :score,                              null: false
+      t.integer :once_ttl,                           null: false
+      t.timestamps limit: 3, null: false
+    end
+    add_index :karma_activities, [:name], unique: true
+
+    create_table :karma_activity_logs do |t|
+      t.integer :o_id,                          null: false
+      t.integer :object_lookup_id,              null: false
+      t.integer :user_id,                       null: false
+      t.integer :activity_id,                   null: false
+      t.integer :score,                         null: false
+      t.integer :score_total,                   null: false
+      t.timestamps limit: 3, null: false
+    end
+    add_index :karma_activity_logs, [:user_id]
+    add_index :karma_activity_logs, [:created_at]
+    add_index :karma_activity_logs, [:o_id, :object_lookup_id]
+
   end
 
   def self.down
+    drop_table :karma_activity_logs
+    drop_table :karma_activities
+    drop_table :karma_users
     drop_table :report_profiles
     drop_table :chat_topics
     drop_table :chat_sessions

+ 0 - 42
db/migrate/20150967000001_create_stats_store.rb

@@ -1,42 +0,0 @@
-class CreateStatsStore < ActiveRecord::Migration
-  def up
-    create_table :stats_stores do |t|
-      t.references :stats_store_object,             null: false
-      t.integer :o_id,                              null: false
-      t.string  :key,                   limit: 250, null: true
-      t.integer :related_o_id,                      null: true
-      t.integer :related_stats_store_object_id,     null: true
-      t.string  :data,                 limit: 2500, null: true
-      t.integer :created_by_id,                     null: false
-      t.timestamps limit: 3, null: false
-    end
-    add_index :stats_stores, [:o_id]
-    add_index :stats_stores, [:key]
-    add_index :stats_stores, [:stats_store_object_id]
-    add_index :stats_stores, [:created_by_id]
-    add_index :stats_stores, [:created_at]
-
-    Scheduler.create_or_update(
-      name: 'Generate user based stats.',
-      method: 'Stats.generate',
-      period: 11.minutes,
-      prio: 2,
-      active: true,
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-    Scheduler.create_or_update(
-      name: 'Delete old stats store entries.',
-      method: 'StatsStore.cleanup',
-      period: 31.days,
-      prio: 2,
-      active: true,
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-  end
-
-  def down
-    drop_table :stats_stores
-  end
-end

+ 0 - 199
db/migrate/20160307000001_only_one_group.rb

@@ -1,199 +0,0 @@
-
-class OnlyOneGroup < ActiveRecord::Migration
-  def up
-    ObjectManager::Attribute.add(
-      force: true,
-      object: 'Ticket',
-      name: 'group_id',
-      display: 'Group',
-      data_type: 'select',
-      data_option: {
-        default: '',
-        relation: 'Group',
-        relation_condition: { access: 'rw' },
-        nulloption: true,
-        multiple: false,
-        null: false,
-        translate: false,
-        only_shown_if_selectable: true,
-      },
-      editable: false,
-      active: true,
-      screens: {
-        create_middle: {
-          '-all-' => {
-            null: false,
-            item_class: 'column',
-          },
-        },
-        edit: {
-          Agent: {
-            null: false,
-          },
-        },
-      },
-      to_create: false,
-      to_migrate: false,
-      to_delete: false,
-      position: 25,
-      created_by_id: 1,
-      updated_by_id: 1,
-    )
-
-    ObjectManager::Attribute.add(
-      force: true,
-      object: 'User',
-      name: 'street',
-      display: 'Street',
-      data_type: 'input',
-      data_option: {
-        type: 'text',
-        maxlength: 100,
-        null: true,
-      },
-      editable: true,
-      active: false,
-      screens: {
-        signup: {},
-        invite_agent: {},
-        invite_customer: {},
-        edit: {
-          '-all-' => {
-            null: true,
-          },
-        },
-        view: {
-          '-all-' => {
-            shown: true,
-          },
-        },
-      },
-      to_create: false,
-      to_migrate: false,
-      to_delete: false,
-      position: 1100,
-      created_by_id: 1,
-      updated_by_id: 1,
-    )
-
-    ObjectManager::Attribute.add(
-      force: true,
-      object: 'User',
-      name: 'zip',
-      display: 'Zip',
-      data_type: 'input',
-      data_option: {
-        type: 'text',
-        maxlength: 100,
-        null: true,
-        item_class: 'formGroup--halfSize',
-      },
-      editable: true,
-      active: false,
-      screens: {
-        signup: {},
-        invite_agent: {},
-        invite_customer: {},
-        edit: {
-          '-all-' => {
-            null: true,
-          },
-        },
-        view: {
-          '-all-' => {
-            shown: true,
-          },
-        },
-      },
-      to_create: false,
-      to_migrate: false,
-      to_delete: false,
-      position: 1200,
-      created_by_id: 1,
-      updated_by_id: 1,
-    )
-
-    ObjectManager::Attribute.add(
-      force: true,
-      object: 'User',
-      name: 'city',
-      display: 'City',
-      data_type: 'input',
-      data_option: {
-        type: 'text',
-        maxlength: 100,
-        null: true,
-        item_class: 'formGroup--halfSize',
-      },
-      editable: true,
-      active: false,
-      screens: {
-        signup: {},
-        invite_agent: {},
-        invite_customer: {},
-        edit: {
-          '-all-' => {
-            null: true,
-          },
-        },
-        view: {
-          '-all-' => {
-            shown: true,
-          },
-        },
-      },
-      to_create: false,
-      to_migrate: false,
-      to_delete: false,
-      position: 1300,
-      created_by_id: 1,
-      updated_by_id: 1,
-    )
-
-    ObjectManager::Attribute.add(
-      force: true,
-      object: 'User',
-      name: 'address',
-      display: 'Address',
-      data_type: 'textarea',
-      data_option: {
-        type: 'text',
-        maxlength: 500,
-        null: true,
-        item_class: 'formGroup--halfSize',
-      },
-      editable: true,
-      active: true,
-      screens: {
-        signup: {},
-        invite_agent: {},
-        invite_customer: {},
-        edit: {
-          '-all-' => {
-            null: true,
-          },
-        },
-        view: {
-          '-all-' => {
-            shown: true,
-          },
-        },
-      },
-      to_create: false,
-      to_migrate: false,
-      to_delete: false,
-      position: 1350,
-      created_by_id: 1,
-      updated_by_id: 1,
-    )
-
-    list = []
-    User.all { |user|
-      next if !user.zip.empty? && !user.city.empty? && !user.street.empty?
-      #next if !user.address.empty?
-      list.push user
-    }
-    list
-  end
-
-end

+ 0 - 49
db/migrate/20160316000006_renew_triggers.rb

@@ -1,49 +0,0 @@
-class RenewTriggers < ActiveRecord::Migration
-  def up
-    drop_table :triggers
-    create_table :triggers do |t|
-      t.column :name,                 :string, limit: 250,  null: false
-      t.column :condition,            :string, limit: 2500, null: false
-      t.column :perform,              :string, limit: 2500, null: false
-      t.column :disable_notification, :boolean,             null: false, default: true
-      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 limit: 3, null: false
-    end
-    add_index :triggers, [:name], unique: true
-
-    drop_table :jobs
-    create_table :jobs do |t|
-      t.column :name,                 :string,  limit: 250,  null: false
-      t.column :timeplan,             :string,  limit: 1000, null: false
-      t.column :condition,            :string,  limit: 2500, null: false
-      t.column :perform,              :string,  limit: 2500, null: false
-      t.column :disable_notification, :boolean,              null: false, default: true
-      t.column :last_run_at,          :timestamp,            null: true
-      t.column :next_run_at,          :timestamp,            null: true
-      t.column :running,              :boolean,              null: false, default: false
-      t.column :processed,            :integer,              null: false, default: 0
-      t.column :matching,             :integer,              null: false, default: 0
-      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 limit: 3, null: false
-    end
-    add_index :jobs, [:name], unique: true
-
-    Scheduler.create_if_not_exists(
-      name: 'Execute jobs',
-      method: 'Job.run',
-      period: 5 * 60,
-      prio: 2,
-      active: true,
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-
-  end
-end

+ 0 - 32
db/migrate/20160417000002_add_http_log.rb

@@ -1,32 +0,0 @@
-class AddHttpLog < ActiveRecord::Migration
-  def up
-
-    create_table :http_logs do |t|
-      t.column :direction,            :string, limit: 20,    null: false
-      t.column :facility,             :string, limit: 100,   null: false
-      t.column :method,               :string, limit: 100,   null: false
-      t.column :url,                  :string, limit: 255,   null: false
-      t.column :status,               :string, limit: 20,    null: true
-      t.column :ip,                   :string, limit: 50,    null: true
-      t.column :request,              :string, limit: 10_000, null: false
-      t.column :response,             :string, limit: 10_000, null: false
-      t.column :updated_by_id,        :integer,              null: true
-      t.column :created_by_id,        :integer,              null: true
-      t.timestamps limit: 3, null: false
-    end
-    add_index :http_logs, [:facility]
-    add_index :http_logs, [:created_by_id]
-    add_index :http_logs, [:created_at]
-
-    Scheduler.create_if_not_exists(
-      name: 'Cleanup HttpLog',
-      method: 'HttpLog.cleanup',
-      period: 24 * 60 * 60,
-      prio: 2,
-      active: true,
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-
-  end
-end

+ 0 - 58
db/migrate/20160422000003_create_cti_log.rb

@@ -1,58 +0,0 @@
-class CreateCtiLog < ActiveRecord::Migration
-  def up
-    create_table :cti_logs do |t|
-      t.string  :direction,              limit: 20,   null: false
-      t.string  :state,                  limit: 20,   null: false
-      t.string  :from,                   limit: 100,  null: false
-      t.string  :from_comment,           limit: 250,  null: true
-      t.string  :to,                     limit: 100,  null: false
-      t.string  :to_comment,             limit: 250,  null: true
-      t.string  :call_id,                limit: 250,  null: false
-      t.string  :comment,                limit: 500,  null: true
-      t.timestamp :start,                limit: 3,    null: true
-      t.timestamp :end,                  limit: 3,    null: true
-      t.boolean   :done,                              null: false, default: true
-      t.text :preferences,            limit: 500.kilobytes + 1, null: true
-      t.timestamps limit: 3, null: false
-    end
-    add_index :cti_logs, [:call_id], unique: true
-    add_index :cti_logs, [:direction]
-    add_index :cti_logs, [:from]
-
-    create_table :cti_caller_ids do |t|
-      t.string  :caller_id,              limit: 100, null: false
-      t.string  :comment,                limit: 500, null: true
-      t.string  :level,                  limit: 100, null: false
-      t.string  :object,                 limit: 100, null: false
-      t.integer :o_id,                               null: false
-      t.integer :user_id,                            null: true
-      t.text    :preferences,            limit: 500.kilobytes + 1, null: true
-      t.timestamps limit: 3, null: false
-    end
-    add_index :cti_caller_ids, [:caller_id]
-    add_index :cti_caller_ids, [:caller_id, :level]
-    add_index :cti_caller_ids, [:caller_id, :user_id]
-    add_index :cti_caller_ids, [:object, :o_id]
-
-    # return if it's a new setup
-    return if !Setting.find_by(name: 'system_init_done')
-
-    Role.create_if_not_exists(
-      name: 'CTI',
-      note: 'Access to CTI feature.',
-      updated_by_id: 1,
-      created_by_id: 1
-    )
-
-    Setting.create_if_not_exists(
-      title: 'Define transaction backend.',
-      name: '9100_cti_caller_id_detection',
-      area: 'Transaction::Backend::Async',
-      description: 'Define the transaction backend which detects caller ids in objects and store them for cti lookups.',
-      options: {},
-      state: 'Transaction::CtiCallerIdDetection',
-      frontend: false
-    )
-
-  end
-end

+ 0 - 15
db/migrate/20160424000002_create_external_sync.rb

@@ -1,15 +0,0 @@
-class CreateExternalSync < ActiveRecord::Migration
-  def up
-    create_table :external_syncs do |t|
-      t.string  :source,                 limit: 100,  null: false
-      t.string  :source_id,              limit: 200,  null: false
-      t.string  :object,                 limit: 100,  null: false
-      t.integer :o_id,                                null: false
-      t.text    :last_payload,           limit: 500.kilobytes + 1, null: true
-      t.timestamps limit: 3, null: false
-    end
-    add_index :external_syncs, [:source, :source_id], unique: true
-    add_index :external_syncs, [:source, :source_id, :object, :o_id], name: 'index_external_syncs_on_source_and_source_id_and_object_o_id'
-    add_index :external_syncs, [:object, :o_id]
-  end
-end

+ 0 - 63
db/migrate/20160501000001_update_transaction.rb

@@ -1,63 +0,0 @@
-class UpdateTransaction < ActiveRecord::Migration
-  def up
-
-    # return if it's a new setup
-    return if !Setting.find_by(name: 'system_init_done')
-
-    Setting.create_or_update(
-      title: 'Define sync transaction backend.',
-      name: '0100_trigger',
-      area: 'Transaction::Backend::Sync',
-      description: 'Define the transaction backend to execute triggers.',
-      options: {},
-      state: 'Transaction::Trigger',
-      frontend: false
-    )
-    Setting.create_or_update(
-      title: 'Define transaction backend.',
-      name: '0100_notification',
-      area: 'Transaction::Backend::Async',
-      description: 'Define the transaction backend to send agent notifications.',
-      options: {},
-      state: 'Transaction::Notification',
-      frontend: false
-    )
-    Setting.create_or_update(
-      title: 'Define transaction backend.',
-      name: '1000_signature_detection',
-      area: 'Transaction::Backend::Async',
-      description: 'Define the transaction backend to detect customers signature in email.',
-      options: {},
-      state: 'Transaction::SignatureDetection',
-      frontend: false
-    )
-    Setting.create_or_update(
-      title: 'Define transaction backend.',
-      name: '6000_slack_webhook',
-      area: 'Transaction::Backend::Async',
-      description: 'Define the transaction backend which posts messages to (http://www.slack.com).',
-      options: {},
-      state: 'Transaction::Slack',
-      frontend: false
-    )
-    Setting.create_or_update(
-      title: 'Define transaction backend.',
-      name: '9000_clearbit_enrichment',
-      area: 'Transaction::Backend::Async',
-      description: 'Define the transaction backend which will enrich customer and organization informations from (http://www.clearbit.com).',
-      options: {},
-      state: 'Transaction::ClearbitEnrichment',
-      frontend: false
-    )
-    Setting.create_or_update(
-      title: 'Define transaction backend.',
-      name: '9100_cti_caller_id_detection',
-      area: 'Transaction::Backend::Async',
-      description: 'Define the transaction backend which detects caller ids in objects and store them for cti lookups.',
-      options: {},
-      state: 'Transaction::CtiCallerIdDetection',
-      frontend: false
-    )
-
-  end
-end

+ 0 - 92
db/migrate/20160503000002_update_trigger.rb

@@ -1,92 +0,0 @@
-class UpdateTrigger < ActiveRecord::Migration
-  def up
-
-    # return if it's a new setup
-    return if !Setting.find_by(name: 'system_init_done')
-
-    Trigger.create_or_update(
-      name: 'auto reply (on new tickets)',
-      condition: {
-        'ticket.action' => {
-          'operator' => 'is',
-          'value' => 'create',
-        },
-        'ticket.state_id' => {
-          'operator' => 'is not',
-          'value' => Ticket::State.lookup(name: 'closed').id,
-        },
-        'article.type_id' => {
-          'operator' => 'is',
-          'value' => [
-            Ticket::Article::Type.lookup(name: 'email').id,
-            Ticket::Article::Type.lookup(name: 'phone').id,
-            Ticket::Article::Type.lookup(name: 'web').id,
-          ],
-        },
-        'article.sender_id' => {
-          'operator' => 'is',
-          'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
-        },
-      },
-      perform: {
-        'notification.email' => {
-          'body' => '<p>Your request (#{config.ticket_hook}#{ticket.number}) has been received and will be reviewed by our support staff.<p>
-<br/>
-<p>To provide additional information, please reply to this email or click on the following link:
-<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
-</p>
-<br/>
-<p>Your #{config.product_name} Team</p>
-<br/>
-<p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
-          'recipient' => 'ticket_customer',
-          'subject' => 'Thanks for your inquiry (#{ticket.title})',
-        },
-      },
-      active: false,
-      created_by_id: 1,
-      updated_by_id: 1,
-    )
-    Trigger.create_or_update(
-      name: 'auto reply (on follow up of tickets)',
-      condition: {
-        'ticket.action' => {
-          'operator' => 'is',
-          'value' => 'update',
-        },
-        'article.sender_id' => {
-          'operator' => 'is',
-          'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
-        },
-        'article.type_id' => {
-          'operator' => 'is',
-          'value' => [
-            Ticket::Article::Type.lookup(name: 'email').id,
-            Ticket::Article::Type.lookup(name: 'phone').id,
-            Ticket::Article::Type.lookup(name: 'web').id,
-          ],
-        },
-      },
-      perform: {
-        'notification.email' => {
-          'body' => '<p>Your follow up for (#{config.ticket_hook}#{ticket.number}) has been received and will be reviewed by our support staff.<p>
-<br/>
-<p>To provide additional information, please reply to this email or click on the following link:
-<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
-</p>
-<br/>
-<p>Your #{config.product_name} Team</p>
-<br/>
-<p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
-          'recipient' => 'ticket_customer',
-          'subject' => 'Thanks for your follow up (#{ticket.title})',
-        },
-      },
-      active: false,
-      created_by_id: 1,
-      updated_by_id: 1,
-    )
-
-  end
-
-end

Some files were not shown because too many files changed in this diff