Merged migrations.

This commit is contained in:
Martin Edenhofer 2016-05-20 12:21:55 +02:00
parent 9bb73f3b43
commit f7ddb4c479
30 changed files with 135 additions and 1720 deletions

View file

@ -66,10 +66,12 @@ class CreateBase < ActiveRecord::Migration
add_index :signatures, [:name], unique: true add_index :signatures, [:name], unique: true
create_table :email_addresses do |t| create_table :email_addresses do |t|
t.integer :channel_id, null: true
t.string :realname, limit: 250, null: false t.string :realname, limit: 250, null: false
t.string :email, limit: 250, null: false t.string :email, limit: 250, null: false
t.boolean :active, null: false, default: true t.boolean :active, null: false, default: true
t.string :note, limit: 250, null: true t.string :note, limit: 250, null: true
t.string :preferences, limit: 2000, null: true
t.integer :updated_by_id, null: false t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false t.integer :created_by_id, null: false
t.timestamps null: false t.timestamps null: false
@ -419,6 +421,21 @@ class CreateBase < ActiveRecord::Migration
end end
add_index :schedulers, [:name], unique: true add_index :schedulers, [:name], unique: true
create_table :calendars do |t|
t.string :name, limit: 250, null: true
t.string :timezone, limit: 250, null: true
t.string :business_hours, limit: 1200, null: true
t.boolean :default, null: false, default: false
t.string :ical_url, limit: 500, null: true
t.text :public_holidays, limit: 500.kilobytes + 1, null: true
t.text :last_log, limit: 500.kilobytes + 1, null: true
t.timestamp :last_sync, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :calendars, [:name], unique: true
create_table :user_devices do |t| create_table :user_devices do |t|
t.references :user, null: false t.references :user, null: false
t.string :name, limit: 250, null: false t.string :name, limit: 250, null: false
@ -438,6 +455,12 @@ class CreateBase < ActiveRecord::Migration
add_index :user_devices, [:updated_at] add_index :user_devices, [:updated_at]
add_index :user_devices, [:created_at] add_index :user_devices, [:created_at]
create_table :external_credentials do |t|
t.string :name
t.string :credentials, limit: 2500, null: false
t.timestamps
end
create_table :object_manager_attributes do |t| create_table :object_manager_attributes do |t|
t.references :object_lookup, null: false t.references :object_lookup, null: false
t.column :name, :string, limit: 200, null: false t.column :name, :string, limit: 200, null: false

View file

@ -13,6 +13,7 @@ class CreateTicket < ActiveRecord::Migration
t.references :state_type, null: false t.references :state_type, null: false
t.column :name, :string, limit: 250, null: false t.column :name, :string, limit: 250, null: false
t.column :next_state_id, :integer, null: true t.column :next_state_id, :integer, null: true
t.column :ignore_escalation, :boolean, null: false, default: false
t.column :note, :string, limit: 250, null: true t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false t.column :updated_by_id, :integer, null: false
@ -340,35 +341,122 @@ class CreateTicket < ActiveRecord::Migration
create_table :channels do |t| create_table :channels do |t|
t.references :group, null: true t.references :group, null: true
t.column :adapter, :string, limit: 100, null: false
t.column :area, :string, limit: 100, null: false t.column :area, :string, limit: 100, null: false
t.column :options, :string, limit: 2000, null: true t.column :options, :string, limit: 2000, null: true
t.column :active, :boolean, null: false, default: true t.column :active, :boolean, null: false, default: true
t.column :preferences, :string, limit: 2000, null: true
t.column :last_log_in, :text, limit: 500.kilobytes + 1, null: true
t.column :last_log_out, :text, limit: 500.kilobytes + 1, null: true
t.column :status_in, :string, limit: 100, null: true
t.column :status_out, :string, limit: 100, null: true
t.column :updated_by_id, :integer, null: false t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false t.column :created_by_id, :integer, null: false
t.timestamps null: false t.timestamps null: false
end end
add_index :channels, [:area] add_index :channels, [:area]
add_index :channels, [:adapter]
create_table :slas do |t| create_table :slas do |t|
t.column :name, :string, limit: 150, null: true t.column :name, :string, limit: 150, null: true
t.column :calendar_id, :integer, null: false
t.column :first_response_time, :integer, null: true t.column :first_response_time, :integer, null: true
t.column :update_time, :integer, null: true t.column :update_time, :integer, null: true
t.column :close_time, :integer, null: true t.column :solution_time, :integer, null: true
t.column :condition, :string, limit: 5000, null: true t.column :condition, :string, limit: 5000, null: true
t.column :data, :string, limit: 5000, null: true
t.column :timezone, :string, limit: 50, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false t.column :created_by_id, :integer, null: false
t.timestamps null: false t.timestamps null: false
end end
add_index :slas, [:name], unique: true add_index :slas, [:name], unique: true
create_table :macros do |t|
t.string :name, limit: 250, null: true
t.string :perform, limit: 5000, null: false
t.boolean :active, null: false, default: true
t.string :note, limit: 250, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :macros, [:name], unique: true
create_table :chats do |t|
t.string :name, limit: 250, null: true
t.integer :max_queue, null: false, default: 5
t.string :note, limit: 250, null: true
t.boolean :active, null: false, default: true
t.boolean :public, null: false, default: false
t.string :preferences, limit: 5000, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :chats, [:name], unique: true
create_table :chat_topics do |t|
t.integer :chat_id, null: false
t.string :name, limit: 250, null: false
t.string :note, limit: 250, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :chat_topics, [:name], unique: true
create_table :chat_sessions do |t|
t.integer :chat_id, null: false
t.string :session_id, null: false
t.string :name, limit: 250, null: true
t.string :state, limit: 50, null: false, default: 'waiting' # running, closed
t.integer :user_id, null: true
t.text :preferences, limit: 100.kilobytes + 1, null: true
t.integer :updated_by_id, null: true
t.integer :created_by_id, null: true
t.timestamps null: false
end
add_index :chat_sessions, [:session_id]
add_index :chat_sessions, [:state]
add_index :chat_sessions, [:user_id]
add_index :chat_sessions, [:chat_id]
create_table :chat_messages do |t|
t.integer :chat_session_id, null: false
t.string :content, limit: 5000, null: false
t.integer :created_by_id, null: true
t.timestamps null: false
end
add_index :chat_messages, [:chat_session_id]
create_table :chat_agents do |t|
t.boolean :active, null: false, default: true
t.integer :concurrent, null: false, default: 5
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :chat_agents, [:active]
add_index :chat_agents, [:updated_by_id], unique: true
add_index :chat_agents, [:created_by_id], unique: true
create_table :report_profiles do |t|
t.column :name, :string, limit: 150, null: true
t.column :condition, :string, limit: 6000, 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 null: false
end
add_index :report_profiles, [:name], unique: true
end end
def self.down def self.down
drop_table :report_profiles
drop_table :chat_topics
drop_table :chat_sessions
drop_table :chat_messages
drop_table :chat_agents
drop_table :chats
drop_table :macros
drop_table :slas drop_table :slas
drop_table :channels drop_table :channels
drop_table :templates_groups drop_table :templates_groups

View file

@ -1,17 +0,0 @@
class FacebookArticleTypes < ActiveRecord::Migration
def up
facebook_at = Ticket::Article::Type.find_by( name: 'facebook' )
return if !facebook_at
facebook_at.name = 'facebook feed post'
facebook_at.save
Ticket::Article::Type.create(
name: 'facebook feed comment',
communication: true,
updated_by_id: 1,
created_by_id: 1
)
end
end

View file

@ -1,59 +0,0 @@
class UpdateChannel < ActiveRecord::Migration
def up
add_column :email_addresses, :channel_id, :integer, null: true
EmailAddress.reset_column_information
channel_inbound = Channel.find_by(area: 'Email::Inbound')
if channel_inbound
EmailAddress.all.each {|email_address|
email_address.channel_id = channel_inbound.id
email_address.save
}
end
add_column :channels, :last_log_in, :text, limit: 500.kilobytes + 1, null: true
add_column :channels, :last_log_out, :text, limit: 500.kilobytes + 1, null: true
add_column :channels, :status_in, :string, limit: 100, null: true
add_column :channels, :status_out, :string, limit: 100, null: true
Channel.reset_column_information
channel_outbound = Channel.find_by(area: 'Email::Outbound', active: true)
Channel.all.each {|channel|
if channel.area == 'Email::Inbound'
channel.area = 'Email::Account'
options = {
inbound: {
adapter: channel.adapter.downcase,
options: channel.options,
},
outbound: {
adapter: channel_outbound.adapter.downcase,
options: channel_outbound.options,
},
}
channel.options = options
channel.save
elsif channel.area == 'Email::Outbound'
channel.area = 'Email::Notification'
options = {
outbound: {
adapter: channel.adapter.downcase,
options: channel.options,
},
}
channel.options = options
channel.save
elsif channel.area == 'Twitter::Inbound'
channel.area = 'Twitter::Account'
channel.options[:adapter] = channel.adapter.downcase
channel.save
end
}
remove_column :channels, :adapter
Channel.reset_column_information
end
end

View file

@ -1,56 +0,0 @@
class AddSettingOnlineService2 < ActiveRecord::Migration
def up
# add preferences
add_column :channels, :preferences, :string, limit: 2000, null: true
Channel.reset_column_information
Channel.where(area: 'Email::Notification').each {|channel|
channel.preferences = {}
channel.preferences[:online_service_disable] = true
channel.save
}
Channel.where(area: 'Email::Account').each {|channel|
next if !channel.options
next if !channel.options[:inbound][:options]
next if !channel.options[:inbound][:options][:host]
next if channel.options[:inbound][:options][:host] !~ /zammad/i
channel.preferences = {}
channel.preferences[:online_service_disable] = true
channel.save
}
add_column :email_addresses, :preferences, :string, limit: 2000, null: true
EmailAddress.reset_column_information
EmailAddress.all.each {|email_address|
next if email_address.email !~ /zammad/i
email_address.preferences = {}
email_address.preferences[:online_service_disable] = true
email_address.save
}
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Setting.create_or_update(
title: 'Block Notifications',
name: 'send_no_auto_response_reg_exp',
area: 'Email::Base',
description: 'If this regex matches, no notification will be send by the sender.',
options: {
form: [
{
display: '',
null: false,
name: 'send_no_auto_response_reg_exp',
tag: 'input',
},
],
},
state: '(MAILER-DAEMON|postmaster|abuse)@.+?\..+?',
preferences: { online_service_disable: true },
frontend: false
)
end
end

View file

@ -1,10 +0,0 @@
class UpdateMessageIdMd5 < ActiveRecord::Migration
def up
Ticket::Article.all.each {|article|
next if !article.message_id
next if article.message_id_md5
message_id_md5 = Digest::MD5.hexdigest(article.message_id)
article.update_columns({ message_id_md5: message_id_md5 })
}
end
end

View file

@ -1,32 +0,0 @@
class CreateCalendar < ActiveRecord::Migration
def up
create_table :calendars do |t|
t.string :name, limit: 250, null: true
t.string :timezone, limit: 250, null: true
t.string :business_hours, limit: 1200, null: true
t.boolean :default, null: false, default: false
t.string :ical_url, limit: 500, null: true
t.text :public_holidays, limit: 500.kilobytes + 1, null: true
t.text :last_log, limit: 500.kilobytes + 1, null: true
t.timestamp :last_sync, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :calendars, [:name], unique: true
Scheduler.create_or_update(
name: 'Sync calendars with ical feeds.',
method: 'Calendar.sync',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
end
def down
drop_table :calendars
end
end

View file

@ -1,8 +0,0 @@
class UpdateSla < ActiveRecord::Migration
def up
add_column :slas, :calendar_id, :integer, null: false
remove_column :slas, :timezone
remove_column :slas, :data
remove_column :slas, :active
end
end

View file

@ -1,6 +0,0 @@
class UpdateTicketState < ActiveRecord::Migration
def up
add_column :ticket_states, :ignore_escalation, :boolean, null: false, default: false
end
end

View file

@ -1,123 +0,0 @@
class UpdateSettings4 < ActiveRecord::Migration
def up
Setting.create_or_update(
title: 'Authentication via Twitter',
name: 'auth_twitter',
area: 'Security::ThirdPartyAuthentication',
description: "@T('Enables user authentication via twitter. Register your app first at [Twitter Developer Site](https://dev.twitter.com/apps)')",
options: {
form: [
{
display: '',
null: true,
name: 'auth_twitter',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
frontend: true
)
Setting.create_or_update(
title: 'Authentication via Facebook',
name: 'auth_facebook',
area: 'Security::ThirdPartyAuthentication',
description: "@T('Enables user authentication via Facebook. Register your app first at [Facebook Developer Site](https://developers.facebook.com/apps/)')",
options: {
form: [
{
display: '',
null: true,
name: 'auth_facebook',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
frontend: true
)
Setting.create_or_update(
title: 'Ticket Hook Position',
name: 'ticket_hook_position',
area: 'Ticket::Base',
description: "@T('The format of the subject.')
* @T('**Right** means **Some Subject [Ticket#12345]**')
* @T('**Left** means **[Ticket#12345] Some Subject**')
* @T('**None** means **Some Subject** (without 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
)
Setting.create_or_update(
title: 'Ticket Number Format',
name: 'ticket_number',
area: 'Ticket::Number',
description: "@T('Selects the ticket number generator module.')
* @T('**Increment** increments the ticket number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).')
* @T('With **Date** the ticket numbers will be generated by the current date, the SystemID and the counter. The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).')
@T('With param 'Checksum => true' the counter will be appended as checksum to the string. The format looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).')",
options: {
form: [
{
display: '',
null: true,
name: 'ticket_number',
tag: 'select',
options: {
'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',
'Ticket::Number::Date' => 'Date (Year.Month.Day.SystemID.Counter)',
},
},
],
},
state: 'Ticket::Number::Increment',
frontend: false
)
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.',
options: {
form: [
{
display: '',
null: true,
name: 'postmaster_follow_up_search_in',
tag: 'checkbox',
options: {
'references' => 'References - Search for follow up also in In-Reply-To or References headers.',
'body' => 'Body - Search for follow up also in mail body.',
'attachment' => 'Attachment - Search for follow up also in attachments.',
},
},
],
},
state: [],
frontend: false
)
end
end

View file

@ -1,222 +0,0 @@
class UpdateOverview3 < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
UserInfo.current_user_id = 1
overview_role = Role.where( name: 'Agent' ).first
Overview.create_or_update(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 7 ],
},
'ticket.owner_id' => {
operator: 'is',
value: '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',
},
)
Overview.create_or_update(
name: 'My pending reached Tickets',
link: 'my_pending_reached',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: 3,
},
'ticket.owner_id' => {
operator: 'is',
value: 'current_user.id',
},
'ticket.pending_time' => {
operator: 'after (relative)',
value: '1',
},
},
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',
},
)
Overview.create_or_update(
name: 'Unassigned & Open Tickets',
link: 'all_unassigned',
prio: 1020,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
'ticket.owner_id' => {
operator: 'is',
value: 1,
},
},
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',
},
)
Overview.create_or_update(
name: 'All Open Tickets',
link: 'all_open',
prio: 1030,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group state owner created_at),
s: %w(title customer group state owner created_at),
m: %w(number title customer group state owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'All pending reached Tickets',
link: 'all_pending_reached',
prio: 1035,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [3],
},
'ticket.pending_time' => {
operator: 'after (relative)',
value: 1,
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner created_at),
s: %w(title customer group owner created_at),
m: %w(number title customer group owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'Escalated Tickets',
link: 'all_escalated',
prio: 1040,
role_id: overview_role.id,
condition: {
'ticket.escalation_time' => {
operator: 'before (relative)',
value: 5,
},
},
order: {
by: 'escalation_time',
direction: 'ASC',
},
view: {
d: %w(title customer group owner escalation_time),
s: %w(title customer group owner escalation_time),
m: %w(number title customer group owner escalation_time),
view_mode_default: 's',
},
)
overview_role = Role.where( name: 'Customer' ).first
Overview.create_or_update(
name: 'My Tickets',
link: 'my_tickets',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6 ],
},
'ticket.customer_id' => {
operator: 'is',
value: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title state created_at),
m: %w(number title state created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'My Organization Tickets',
link: 'my_organization_tickets',
prio: 1100,
role_id: overview_role.id,
organization_shared: true,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6 ],
},
'ticket.organization_id' => {
operator: 'is',
value: 'current_user.organization_id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title customer state created_at),
m: %w(number title customer state created_at),
view_mode_default: 's',
},
)
end
end

View file

@ -1,5 +0,0 @@
class UpdateSla1 < ActiveRecord::Migration
def up
rename_column :slas, :close_time, :solution_time
end
end

View file

@ -1,28 +0,0 @@
class UpdateSettings5 < ActiveRecord::Migration
def up
Setting.create_or_update(
title: 'Geo Calendar Service',
name: 'geo_calendar_backend',
area: 'System::Services',
description: 'Defines the backend for geo calendar lookups. Used for inital calendar succession.',
options: {
form: [
{
display: '',
null: true,
name: 'geo_calendar_backend',
tag: 'select',
options: {
'' => '-',
'Service::GeoCalendar::Zammad' => 'Zammad GeoCalendar Service',
},
},
],
},
state: 'Service::GeoCalendar::Zammad',
preferences: { prio: 2 },
frontend: false
)
Calendar.init_setup
end
end

View file

@ -1,12 +0,0 @@
class UpdateTicketState2 < ActiveRecord::Migration
def up
return if !Ticket::State.first
Ticket::State.create_or_update( id: 3, name: 'pending reminder', state_type_id: Ticket::StateType.find_by(name: 'pending reminder').id, ignore_escalation: true )
Ticket::State.create_or_update( id: 4, name: 'closed', state_type_id: Ticket::StateType.find_by(name: 'closed').id, ignore_escalation: true )
Ticket::State.create_or_update( id: 5, name: 'merged', state_type_id: Ticket::StateType.find_by(name: 'merged').id, ignore_escalation: true )
Ticket::State.create_or_update( id: 6, name: 'removed', state_type_id: Ticket::StateType.find_by(name: 'removed').id, active: false, ignore_escalation: true )
Ticket::State.create_or_update( id: 7, name: 'pending close', state_type_id: Ticket::StateType.find_by(name: 'pending action').id, next_state_id: 4, ignore_escalation: true )
end
end

View file

@ -1,77 +0,0 @@
class UpdateObjectManager3 < ActiveRecord::Migration
def up
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'organization_id',
display: 'Organization',
data_type: 'autocompletion_ajax',
data_option: {
multiple: false,
nulloption: true,
null: true,
relation: 'Organization',
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 900,
created_by_id: 1,
updated_by_id: 1,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'customer_id',
display: 'Customer',
data_type: 'user_autocompletion',
data_option: {
relation: 'User',
autocapitalize: false,
multiple: false,
null: false,
limit: 200,
placeholder: 'Enter Person or Organization/Company',
minLengt: 2,
translate: false,
},
editable: false,
active: true,
screens: {
create_top: {
Agent: {
null: false,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 10,
created_by_id: 1,
updated_by_id: 1,
)
end
end

View file

@ -1,6 +0,0 @@
class UpdateSettings6 < ActiveRecord::Migration
def up
return if !Setting.column_names.include?('state')
rename_column :settings, :state, :state_current
end
end

View file

@ -1,289 +0,0 @@
class UpdateOverview4 < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
UserInfo.current_user_id = 1
overview_role = Role.where( name: 'Agent' ).first
Overview.create_or_update(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 7 ],
},
'ticket.owner_id' => {
operator: 'is',
value: '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',
},
)
Overview.create_or_update(
name: 'My pending reached Tickets',
link: 'my_pending_reached',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: 3,
},
'ticket.owner_id' => {
operator: 'is',
value: 'current_user.id',
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
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',
},
)
Overview.create_or_update(
name: 'Unassigned & Open Tickets',
link: 'all_unassigned',
prio: 1020,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
'ticket.owner_id' => {
operator: 'is',
value: 1,
},
},
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',
},
)
Overview.create_or_update(
name: 'All Open Tickets',
link: 'all_open',
prio: 1030,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group state owner created_at),
s: %w(title customer group state owner created_at),
m: %w(number title customer group state owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'All pending reached Tickets',
link: 'all_pending_reached',
prio: 1035,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [3],
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner created_at),
s: %w(title customer group owner created_at),
m: %w(number title customer group owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'Escalated Tickets',
link: 'all_escalated',
prio: 1040,
role_id: overview_role.id,
condition: {
'ticket.escalation_time' => {
operator: 'within next (relative)',
value: '10',
range: 'minute',
},
},
order: {
by: 'escalation_time',
direction: 'ASC',
},
view: {
d: %w(title customer group owner escalation_time),
s: %w(title customer group owner escalation_time),
m: %w(number title customer group owner escalation_time),
view_mode_default: 's',
},
)
overview_role = Role.where( name: 'Customer' ).first
Overview.create_or_update(
name: 'My Tickets',
link: 'my_tickets',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
},
'ticket.customer_id' => {
operator: 'is',
value: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title state created_at),
m: %w(number title state created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'My Organization Tickets',
link: 'my_organization_tickets',
prio: 1100,
role_id: overview_role.id,
organization_shared: true,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
},
'ticket.organization_id' => {
operator: 'is',
value: 'current_user.organization_id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title customer state created_at),
m: %w(number title customer state created_at),
view_mode_default: 's',
},
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'title',
display: 'Title',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 200,
null: false,
translate: false,
},
editable: false,
active: true,
screens: {
create_top: {
'-all-' => {
null: false,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 15,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'group_id',
display: 'Group',
data_type: 'select',
data_option: {
relation: 'Group',
relation_condition: { access: 'rw' },
nulloption: true,
multiple: false,
null: false,
translate: false,
},
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,
)
end
end

View file

@ -1,226 +0,0 @@
class UpdateOverview5 < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
UserInfo.current_user_id = 1
overview_role = Role.where( name: 'Agent' ).first
Overview.create_or_update(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 7 ],
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: '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',
},
)
Overview.create_or_update(
name: 'My pending reached Tickets',
link: 'my_pending_reached',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: 3,
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
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',
},
)
Overview.create_or_update(
name: 'Unassigned & Open Tickets',
link: 'all_unassigned',
prio: 1020,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
'ticket.owner_id' => {
operator: 'is',
value: 1,
},
},
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',
},
)
Overview.create_or_update(
name: 'All Open Tickets',
link: 'all_open',
prio: 1030,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group state owner created_at),
s: %w(title customer group state owner created_at),
m: %w(number title customer group state owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'All pending reached Tickets',
link: 'all_pending_reached',
prio: 1035,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [3],
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner created_at),
s: %w(title customer group owner created_at),
m: %w(number title customer group owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'Escalated Tickets',
link: 'all_escalated',
prio: 1040,
role_id: overview_role.id,
condition: {
'ticket.escalation_time' => {
operator: 'within next (relative)',
value: '10',
range: 'minute',
},
},
order: {
by: 'escalation_time',
direction: 'ASC',
},
view: {
d: %w(title customer group owner escalation_time),
s: %w(title customer group owner escalation_time),
m: %w(number title customer group owner escalation_time),
view_mode_default: 's',
},
)
overview_role = Role.where( name: 'Customer' ).first
Overview.create_or_update(
name: 'My Tickets',
link: 'my_tickets',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
},
'ticket.customer_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title state created_at),
m: %w(number title state created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'My Organization Tickets',
link: 'my_organization_tickets',
prio: 1100,
role_id: overview_role.id,
organization_shared: true,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
},
'ticket.organization_id' => {
operator: 'is',
pre_condition: 'current_user.organization_id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title customer state created_at),
m: %w(number title customer state created_at),
view_mode_default: 's',
},
)
end
end

View file

@ -1,37 +0,0 @@
class CreateMacro < ActiveRecord::Migration
def up
create_table :macros do |t|
t.string :name, limit: 250, null: true
t.string :perform, limit: 5000, null: false
t.boolean :active, null: false, default: true
t.string :note, limit: 250, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :macros, [:name], unique: true
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
UserInfo.current_user_id = 1
Macro.create_or_update(
name: 'Close & Tag as Spam',
perform: {
'ticket.state_id' => {
value: Ticket::State.find_by(name: 'closed').id,
},
'ticket.tags' => {
operator: 'add',
value: 'spam',
},
},
note: 'example macro',
active: true,
)
end
def down
drop_table :macros
end
end

View file

@ -1,29 +0,0 @@
class CreateReport < ActiveRecord::Migration
def up
create_table :report_profiles do |t|
t.column :name, :string, limit: 150, null: true
t.column :condition, :string, limit: 6000, 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 null: false
end
add_index :report_profiles, [:name], unique: true
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Report::Profile.create_if_not_exists(
name: '-all-',
condition: {},
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Role.create_if_not_exists(name: 'Report', created_by_id: 1, updated_by_id: 1)
end
def down
drop_table :report_profiles
end
end

View file

@ -1,227 +0,0 @@
class UpdateOverview6 < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
UserInfo.current_user_id = 1
Overview.destroy_all
overview_role = Role.where( name: 'Agent' ).first
Overview.create_or_update(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 7 ],
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: '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',
},
)
Overview.create_or_update(
name: 'Unassigned & Open',
link: 'all_unassigned',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
'ticket.owner_id' => {
operator: 'is',
value: 1,
},
},
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',
},
)
Overview.create_or_update(
name: 'My pending reached Tickets',
link: 'my_pending_reached',
prio: 1020,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: 3,
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
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',
},
)
Overview.create_or_update(
name: 'Open',
link: 'all_open',
prio: 1030,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group state owner created_at),
s: %w(title customer group state owner created_at),
m: %w(number title customer group state owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'Pending reached',
link: 'all_pending_reached',
prio: 1040,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [3],
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner created_at),
s: %w(title customer group owner created_at),
m: %w(number title customer group owner created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'Escalated',
link: 'all_escalated',
prio: 1050,
role_id: overview_role.id,
condition: {
'ticket.escalation_time' => {
operator: 'within next (relative)',
value: '10',
range: 'minute',
},
},
order: {
by: 'escalation_time',
direction: 'ASC',
},
view: {
d: %w(title customer group owner escalation_time),
s: %w(title customer group owner escalation_time),
m: %w(number title customer group owner escalation_time),
view_mode_default: 's',
},
)
overview_role = Role.where( name: 'Customer' ).first
Overview.create_or_update(
name: 'My Tickets',
link: 'my_tickets',
prio: 1100,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
},
'ticket.customer_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title state created_at),
m: %w(number title state created_at),
view_mode_default: 's',
},
)
Overview.create_or_update(
name: 'My Organization Tickets',
link: 'my_organization_tickets',
prio: 1200,
role_id: overview_role.id,
organization_shared: true,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
},
'ticket.organization_id' => {
operator: 'is',
pre_condition: 'current_user.organization_id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title customer state created_at),
m: %w(number title customer state created_at),
view_mode_default: 's',
},
)
end
end

View file

@ -1,108 +0,0 @@
class CreateChat < ActiveRecord::Migration
def up
create_table :chats do |t|
t.string :name, limit: 250, null: true
t.integer :max_queue, null: false, default: 5
t.string :note, limit: 250, null: true
t.boolean :active, null: false, default: true
t.boolean :public, null: false, default: false
t.string :preferences, limit: 5000, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :chats, [:name], unique: true
create_table :chat_topics do |t|
t.integer :chat_id, null: false
t.string :name, limit: 250, null: false
t.string :note, limit: 250, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :chat_topics, [:name], unique: true
create_table :chat_sessions do |t|
t.integer :chat_id, null: false
t.string :session_id, null: false
t.string :name, limit: 250, null: true
t.string :state, limit: 50, null: false, default: 'waiting' # running, closed
t.integer :user_id, null: true
t.text :preferences, limit: 100.kilobytes + 1, null: true
t.integer :updated_by_id, null: true
t.integer :created_by_id, null: true
t.timestamps null: false
end
add_index :chat_sessions, [:session_id]
add_index :chat_sessions, [:state]
add_index :chat_sessions, [:user_id]
add_index :chat_sessions, [:chat_id]
create_table :chat_messages do |t|
t.integer :chat_session_id, null: false
t.string :content, limit: 5000, null: false
t.integer :created_by_id, null: true
t.timestamps null: false
end
add_index :chat_messages, [:chat_session_id]
create_table :chat_agents do |t|
t.boolean :active, null: false, default: true
t.integer :concurrent, null: false, default: 5
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps null: false
end
add_index :chat_agents, [:active]
add_index :chat_agents, [:updated_by_id], unique: true
add_index :chat_agents, [:created_by_id], unique: true
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Role.create_if_not_exists(
name: 'Chat',
note: 'Access to chat feature.',
updated_by_id: 1,
created_by_id: 1
)
chat = Chat.create(
name: 'default',
max_queue: 5,
note: '',
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Closed chat sessions where participients are offline.',
method: 'Chat.cleanup_close',
period: 60 * 15,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Cleanup closed sessions.',
method: 'Chat.cleanup',
period: 5.days,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
end
def down
drop_table :chat_topics
drop_table :chat_sessions
drop_table :chat_messages
drop_table :chat_agents
drop_table :chats
end
end

View file

@ -1,10 +0,0 @@
class CreateExternalCredentials < ActiveRecord::Migration
def change
create_table :external_credentials do |t|
t.string :name
t.string :credentials, limit: 2500, null: false
t.timestamps null: false
end
end
end

View file

@ -1,61 +0,0 @@
class ZendeskImportSettings < ActiveRecord::Migration
def change
Setting.create_if_not_exists(
title: 'Import Endpoint',
name: 'import_zendesk_endpoint',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint to import users, ticket, states and articles.',
options: {
form: [
{
display: '',
null: false,
name: 'import_zendesk_endpoint',
tag: 'input',
},
],
},
state: 'https://yours.zendesk.com/api/v2',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Key for requesting the Zendesk API',
name: 'import_zendesk_endpoint_key',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint auth key.',
options: {
form: [
{
display: '',
null: false,
name: 'import_zendesk_endpoint_key',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import User for requesting the Zendesk API',
name: 'import_zendesk_endpoint_username',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint auth key.',
options: {
form: [
{
display: '',
null: true,
name: 'import_zendesk_endpoint_username',
tag: 'input',
},
],
},
state: '',
frontend: false
)
end
end

View file

@ -1,25 +0,0 @@
class UpdateChat5 < ActiveRecord::Migration
def change
Setting.create_if_not_exists(
title: 'Agent idle timeout',
name: 'chat_agent_idle_timeout',
area: 'Chat::Extended',
description: 'Idle timeout in seconds till agent is set offline automatically.',
options: {
form: [
{
display: '',
null: false,
name: 'chat_agent_idle_timeout',
tag: 'input',
},
],
},
preferences: {},
state: '120',
frontend: true
)
end
end

View file

@ -1,5 +0,0 @@
class UpdateAuth < ActiveRecord::Migration
def up
Setting.where(name: 'auth_otrs').destroy_all
end
end

View file

@ -1,6 +0,0 @@
class UpdtateTimeSlaTime < ActiveRecord::Migration
def up
return if !Ticket.column_names.include?('updtate_time_sla_time')
rename_column :tickets, :updtate_time_sla_time, :update_time_sla_time
end
end

View file

@ -1,12 +0,0 @@
class MigrateTextModules < ActiveRecord::Migration
def up
TextModule.all.each {|text_module|
text_module.content = text_module.content.text2html
text_module.save
}
Signature.all.each {|signature|
signature.body = signature.body.text2html
signature.save
}
end
end

View file

@ -1,9 +0,0 @@
class MigrateTextModules2 < ActiveRecord::Migration
def up
TextModule.all.each {|text_module|
text_module.content.gsub!('&lt;%=', '#{')
text_module.content.gsub!('%&gt;', '}')
text_module.save
}
end
end

View file

@ -1174,7 +1174,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
state: '(mailer-daemon|postmaster|abuse|root)@.+?\..+?', state: '(mailer-daemon|postmaster|abuse|root|noreply|noreply.+?)@.+?\..+?',
preferences: { online_service_disable: true }, preferences: { online_service_disable: true },
frontend: false frontend: false
) )
@ -4199,6 +4199,15 @@ Scheduler.create_or_update(
updated_by_id: 1, updated_by_id: 1,
created_by_id: 1, created_by_id: 1,
) )
Scheduler.create_or_update(
name: 'Sync calendars with ical feeds.',
method: 'Calendar.sync',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Trigger.create_or_update( Trigger.create_or_update(
name: 'auto reply (on new tickets)', name: 'auto reply (on new tickets)',