Maintenance: Introduced custom Rubocop Zammad/ExistsConditions
to check for .find_by
in conditions and replace it with .exists?
to increase performance and reduce memory cost.
This commit is contained in:
parent
5239c83e71
commit
f5841a2fe3
158 changed files with 285 additions and 163 deletions
120
.rubocop/cop/zammad/exists_condition.rb
Normal file
120
.rubocop/cop/zammad/exists_condition.rb
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
module RuboCop
|
||||||
|
module Cop
|
||||||
|
module Zammad
|
||||||
|
# This cop is used to identify usages of `find_by` in conditions and
|
||||||
|
# changes them to use `exists?` instead.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# # bad
|
||||||
|
# if User.find_by(name: 'Rubocop')
|
||||||
|
# if !User.find_by(name: 'Rubocop')
|
||||||
|
# unless User.find_by(name: 'Rubocop')
|
||||||
|
# if find_by(name: 'Rubocop')
|
||||||
|
# if !find_by(name: 'Rubocop')
|
||||||
|
# unless find_by(name: 'Rubocop')
|
||||||
|
#
|
||||||
|
# # good
|
||||||
|
# if User.exists?(name: 'Rubocop')
|
||||||
|
# if !User.exists?(name: 'Rubocop')
|
||||||
|
# unless User.exists?(name: 'Rubocop')
|
||||||
|
# if exists?(name: 'Rubocop')
|
||||||
|
# if !exists?(name: 'Rubocop')
|
||||||
|
# unless exists?(name: 'Rubocop')
|
||||||
|
class ExistsCondition < Cop
|
||||||
|
|
||||||
|
def_node_matcher :find_by_condition?, <<-PATTERN
|
||||||
|
{
|
||||||
|
$(send $_ :find_by ...)
|
||||||
|
(send $(send $_ :find_by ...) :!)
|
||||||
|
}
|
||||||
|
PATTERN
|
||||||
|
|
||||||
|
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'.freeze
|
||||||
|
|
||||||
|
def on_if(node)
|
||||||
|
check_for_find_by(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_while(node)
|
||||||
|
check_for_find_by(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_while_post(node)
|
||||||
|
check_for_find_by(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_until(node)
|
||||||
|
check_for_find_by(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_until_post(node)
|
||||||
|
check_for_find_by(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
def autocorrect(node)
|
||||||
|
lambda do |corrector|
|
||||||
|
corrector.replace(node.loc.selector, 'exists?')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_for_find_by(node)
|
||||||
|
cond = condition(node)
|
||||||
|
handle_node(cond)
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_node(node)
|
||||||
|
return unless node
|
||||||
|
|
||||||
|
if keyword_bang?(node)
|
||||||
|
receiver, = *node
|
||||||
|
|
||||||
|
handle_node(receiver)
|
||||||
|
elsif node.operator_keyword?
|
||||||
|
node.each_child_node { |op| handle_node(op) }
|
||||||
|
elsif node.begin_type? && node.children.one?
|
||||||
|
handle_node(node.children.first)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def keyword_bang?(node)
|
||||||
|
node.respond_to?(:keyword_bang?) && node.keyword_bang?
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_node(node)
|
||||||
|
if node.send_type?
|
||||||
|
check_offense(*find_by_condition?(node)) # rubocop:disable Rails/DynamicFindBy
|
||||||
|
elsif %i[and or begin].include?(node.type)
|
||||||
|
check_node(node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def condition(node)
|
||||||
|
if node.send_type?
|
||||||
|
node.receiver
|
||||||
|
else
|
||||||
|
node.condition
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_offense(method_call = nil, receiver = nil)
|
||||||
|
return if method_call.nil?
|
||||||
|
|
||||||
|
add_offense(method_call,
|
||||||
|
message: format(MSG,
|
||||||
|
prefer: replacement(receiver),
|
||||||
|
current: current(receiver)))
|
||||||
|
end
|
||||||
|
|
||||||
|
def current(node)
|
||||||
|
node.respond_to?(:source) ? "#{node.source}.find_by" : 'find_by'
|
||||||
|
end
|
||||||
|
|
||||||
|
def replacement(node)
|
||||||
|
node.respond_to?(:source) ? "#{node.source}.exists?" : 'exists?'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,6 +5,7 @@ require:
|
||||||
- rubocop-performance
|
- rubocop-performance
|
||||||
- rubocop-rails
|
- rubocop-rails
|
||||||
- rubocop-rspec
|
- rubocop-rspec
|
||||||
|
- ./rubocop_zammad.rb
|
||||||
|
|
||||||
inherit_from:
|
inherit_from:
|
||||||
- todo.yml
|
- todo.yml
|
||||||
|
|
1
.rubocop/rubocop_zammad.rb
Normal file
1
.rubocop/rubocop_zammad.rb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
require_relative 'cop/zammad/exists_condition'
|
|
@ -31,7 +31,7 @@ class ChannelsEmailController < ApplicationController
|
||||||
|
|
||||||
email_address_ids.push email_address.id
|
email_address_ids.push email_address.id
|
||||||
assets = email_address.assets(assets)
|
assets = email_address.assets(assets)
|
||||||
if !email_address.channel_id || !email_address.active || !Channel.find_by(id: email_address.channel_id)
|
if !email_address.channel_id || !email_address.active || !Channel.exists?(id: email_address.channel_id)
|
||||||
not_used_email_address_ids.push email_address.id
|
not_used_email_address_ids.push email_address.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -360,7 +360,7 @@ returns
|
||||||
|
|
||||||
# check if min one is set to default true
|
# check if min one is set to default true
|
||||||
def min_one_check
|
def min_one_check
|
||||||
if !Calendar.find_by(default: true)
|
if !Calendar.exists?(default: true)
|
||||||
first = Calendar.order(:created_at, :id).limit(1).first
|
first = Calendar.order(:created_at, :id).limit(1).first
|
||||||
return true if !first
|
return true if !first
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ returns
|
||||||
sla.save!
|
sla.save!
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if !Calendar.find_by(id: sla.calendar_id)
|
if !Calendar.exists?(id: sla.calendar_id)
|
||||||
sla.calendar_id = default_calendar.id
|
sla.calendar_id = default_calendar.id
|
||||||
sla.save!
|
sla.save!
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Channel::Driver::Sms::Twilio
|
||||||
Rails.logger.info "Receiving SMS frim recipient #{attr[:From]}"
|
Rails.logger.info "Receiving SMS frim recipient #{attr[:From]}"
|
||||||
|
|
||||||
# prevent already created articles
|
# prevent already created articles
|
||||||
if Ticket::Article.find_by(message_id: attr[:SmsMessageSid])
|
if Ticket::Article.exists?(message_id: attr[:SmsMessageSid])
|
||||||
return ['application/xml; charset=UTF-8;', Twilio::TwiML::MessagingResponse.new.to_s]
|
return ['application/xml; charset=UTF-8;', Twilio::TwiML::MessagingResponse.new.to_s]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
next if @client.locale_sender?(tweet) && own_tweet_already_imported?(tweet)
|
next if @client.locale_sender?(tweet) && own_tweet_already_imported?(tweet)
|
||||||
next if Ticket::Article.find_by(message_id: tweet.id)
|
next if Ticket::Article.exists?(message_id: tweet.id)
|
||||||
break if @client.tweet_limit_reached(tweet)
|
break if @client.tweet_limit_reached(tweet)
|
||||||
|
|
||||||
@client.to_group(tweet, search[:group_id], @channel)
|
@client.to_group(tweet, search[:group_id], @channel)
|
||||||
|
@ -202,7 +202,7 @@ returns
|
||||||
event_time = Time.zone.now
|
event_time = Time.zone.now
|
||||||
sleep 4
|
sleep 4
|
||||||
12.times do |loop_count|
|
12.times do |loop_count|
|
||||||
if Ticket::Article.find_by(message_id: tweet.id)
|
if Ticket::Article.exists?(message_id: tweet.id)
|
||||||
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
|
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -215,7 +215,7 @@ returns
|
||||||
sleep sleep_time
|
sleep sleep_time
|
||||||
end
|
end
|
||||||
|
|
||||||
if Ticket::Article.find_by(message_id: tweet.id)
|
if Ticket::Article.exists?(message_id: tweet.id)
|
||||||
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
|
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,7 +35,7 @@ module Channel::Filter::IdentifySender
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
|
|
||||||
# skip if recipient is system email
|
# skip if recipient is system email
|
||||||
next if EmailAddress.find_by(email: item.address.downcase)
|
next if EmailAddress.exists?(email: item.address.downcase)
|
||||||
|
|
||||||
customer_user = user_create(
|
customer_user = user_create(
|
||||||
login: item.address,
|
login: item.address,
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Channel::Filter::SenderIsSystemAddress
|
||||||
|
|
||||||
items = mail[form].addrs
|
items = mail[form].addrs
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
next if !EmailAddress.find_by(email: item.address.downcase)
|
next if !EmailAddress.exists?(email: item.address.downcase)
|
||||||
|
|
||||||
mail['x-zammad-ticket-create-article-sender'.to_sym] = 'Agent'
|
mail['x-zammad-ticket-create-article-sender'.to_sym] = 'Agent'
|
||||||
mail['x-zammad-article-sender'.to_sym] = 'Agent'
|
mail['x-zammad-article-sender'.to_sym] = 'Agent'
|
||||||
|
|
|
@ -63,7 +63,7 @@ check and if channel not exists reset configured channels for email addresses
|
||||||
def check_if_channel_exists_set_inactive
|
def check_if_channel_exists_set_inactive
|
||||||
|
|
||||||
# set to active if channel exists
|
# set to active if channel exists
|
||||||
if channel_id && Channel.find_by(id: channel_id)
|
if channel_id && Channel.exists?(id: channel_id)
|
||||||
self.active = true
|
self.active = true
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ Tag::Item.rename(
|
||||||
Tag.where(tag_item_id: old_tag_item.id).each do |tag|
|
Tag.where(tag_item_id: old_tag_item.id).each do |tag|
|
||||||
|
|
||||||
# check if tag already exists on object
|
# check if tag already exists on object
|
||||||
if Tag.find_by(tag_object_id: tag.tag_object_id, o_id: tag.o_id, tag_item_id: already_existing_tag.id)
|
if Tag.exists?(tag_object_id: tag.tag_object_id, o_id: tag.o_id, tag_item_id: already_existing_tag.id)
|
||||||
Tag.tag_remove(
|
Tag.tag_remove(
|
||||||
tag_object_id: tag.tag_object_id,
|
tag_object_id: tag.tag_object_id,
|
||||||
o_id: tag.o_id,
|
o_id: tag.o_id,
|
||||||
|
|
|
@ -1046,7 +1046,7 @@ try to find correct name
|
||||||
raise Exceptions::UnprocessableEntity, 'out of office end is required' if out_of_office_end_at.blank?
|
raise Exceptions::UnprocessableEntity, 'out of office end is required' if out_of_office_end_at.blank?
|
||||||
raise Exceptions::UnprocessableEntity, 'out of office end is before start' if out_of_office_start_at > out_of_office_end_at
|
raise Exceptions::UnprocessableEntity, 'out of office end is before start' if out_of_office_start_at > out_of_office_end_at
|
||||||
raise Exceptions::UnprocessableEntity, 'out of office replacement user is required' if out_of_office_replacement_id.blank?
|
raise Exceptions::UnprocessableEntity, 'out of office replacement user is required' if out_of_office_replacement_id.blank?
|
||||||
raise Exceptions::UnprocessableEntity, 'out of office no such replacement user' if !User.find_by(id: out_of_office_replacement_id)
|
raise Exceptions::UnprocessableEntity, 'out of office no such replacement user' if !User.exists?(id: out_of_office_replacement_id)
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class UpdateTimestamps < ActiveRecord::Migration[4.2]
|
class UpdateTimestamps < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
# get all models
|
# get all models
|
||||||
Models.all.each_value do |value|
|
Models.all.each_value do |value|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ObjectManagerUpdateUser < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
ObjectManager::Attribute.add(
|
ObjectManager::Attribute.add(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class PermissionActive < ActiveRecord::Migration[4.2]
|
class PermissionActive < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :permissions, :active, :boolean, null: false, default: true
|
add_column :permissions, :active, :boolean, null: false, default: true
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2]
|
class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :organizations, :domain, :string, limit: 250, null: true, default: ''
|
add_column :organizations, :domain, :string, limit: 250, null: true, default: ''
|
||||||
add_column :organizations, :domain_assignment, :boolean, null: false, default: false
|
add_column :organizations, :domain_assignment, :boolean, null: false, default: false
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class JobUnableToCreateIssue432 < ActiveRecord::Migration[4.2]
|
class JobUnableToCreateIssue432 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
ActiveRecord::Migration.change_table :jobs do |t|
|
ActiveRecord::Migration.change_table :jobs do |t|
|
||||||
t.change :timeplan, :string, limit: 2500
|
t.change :timeplan, :string, limit: 2500
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class TicketNumberGeneratorIssue427 < ActiveRecord::Migration[4.2]
|
class TicketNumberGeneratorIssue427 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'ticket_number')
|
setting = Setting.find_by(name: 'ticket_number')
|
||||||
setting.preferences = {
|
setting.preferences = {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration[4.2]
|
class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'storage')
|
setting = Setting.find_by(name: 'storage')
|
||||||
return if !setting
|
return if !setting
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class MonitoringIssue453 < ActiveRecord::Migration[4.2]
|
class MonitoringIssue453 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Monitoring Token',
|
title: 'Monitoring Token',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class AddTaskbarMeta < ActiveRecord::Migration[4.2]
|
class AddTaskbarMeta < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :taskbars, :preferences, :text, limit: 5.megabytes + 1, null: true
|
add_column :taskbars, :preferences, :text, limit: 5.megabytes + 1, null: true
|
||||||
add_index :taskbars, [:key]
|
add_index :taskbars, [:key]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class ObjectManagerAttributeCreateMiddle < ActiveRecord::Migration[4.2]
|
class ObjectManagerAttributeCreateMiddle < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
ObjectManager::Attribute.all.each do |attribute|
|
ObjectManager::Attribute.all.each do |attribute|
|
||||||
next if attribute.name == 'tags'
|
next if attribute.name == 'tags'
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SlackGroupConfigIssue587 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'slack_config')
|
setting = Setting.find_by(name: 'slack_config')
|
||||||
return if !setting
|
return if !setting
|
||||||
|
|
|
@ -2,7 +2,7 @@ class AddTicketTimeAccounting373 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
drop_table :ticket_time_accounting
|
drop_table :ticket_time_accounting
|
||||||
create_table :ticket_time_accountings do |t|
|
create_table :ticket_time_accountings do |t|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FixedTypos622 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'ticket_define_email_from_seperator')
|
setting = Setting.find_by(name: 'ticket_define_email_from_seperator')
|
||||||
return if !setting
|
return if !setting
|
||||||
|
|
|
@ -2,7 +2,7 @@ class UnableToEnableTimeAccounting633 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Time Accounting',
|
title: 'Time Accounting',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class LoginEmailLength650 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
change_column(:users, :login, :string, limit: 255)
|
change_column(:users, :login, :string, limit: 255)
|
||||||
change_column(:users, :email, :string, limit: 255)
|
change_column(:users, :email, :string, limit: 255)
|
||||||
|
|
|
@ -2,7 +2,7 @@ class UiTicketZoomArticleNewInternal < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Define default visibility of new a new article',
|
title: 'Define default visibility of new a new article',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FixedTranslation < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
settings_update = [
|
settings_update = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ApplicationSecretSetting < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Application secret',
|
title: 'Application secret',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FollowUpPossibleCheck643 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Define postmaster filter.',
|
title: 'Define postmaster filter.',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class RemoveLastLoginFromHistory722 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
history_object = History.object_lookup('User')
|
history_object = History.object_lookup('User')
|
||||||
return if !history_object
|
return if !history_object
|
||||||
|
|
|
@ -2,7 +2,7 @@ class DoNotImportOnwNotifications731 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Define postmaster filter.',
|
title: 'Define postmaster filter.',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class TicketStatePriorityDefaults < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :ticket_states, :default_create, :boolean, null: false, default: false
|
add_column :ticket_states, :default_create, :boolean, null: false, default: false
|
||||||
add_index :ticket_states, :default_create
|
add_index :ticket_states, :default_create
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ReloadOnlineBrowserAfterCorsCsrfChanges < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
AppVersion.set(true, 'app_version')
|
AppVersion.set(true, 'app_version')
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class TelegramSupport < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Permission.create_if_not_exists(
|
Permission.create_if_not_exists(
|
||||||
name: 'admin.channel_telegram',
|
name: 'admin.channel_telegram',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FixedTranslation2 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
settings_update = [
|
settings_update = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FixedAdminUserPermission920 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
ObjectManager::Attribute.add(
|
ObjectManager::Attribute.add(
|
||||||
force: true,
|
force: true,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class ValidateAgentLimit < ActiveRecord::Migration[4.2]
|
class ValidateAgentLimit < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Set limit of agents',
|
title: 'Set limit of agents',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class LdapSupport < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
if !ActiveRecord::Base.connection.table_exists? 'import_jobs'
|
if !ActiveRecord::Base.connection.table_exists? 'import_jobs'
|
||||||
create_table :import_jobs do |t|
|
create_table :import_jobs do |t|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class OverviewRoleIds < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
create_table :overviews_roles, id: false do |t|
|
create_table :overviews_roles, id: false do |t|
|
||||||
t.integer :overview_id
|
t.integer :overview_id
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ChatIncreaseMessageSize < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
change_column :chat_messages, :content, :text, limit: 20.megabytes + 1, null: false
|
change_column :chat_messages, :content, :text, limit: 20.megabytes + 1, null: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class PrettyDateOptionsAdded < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_or_update(
|
Setting.create_or_update(
|
||||||
title: 'Pretty Date',
|
title: 'Pretty Date',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class AddOriginById < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :ticket_articles, :origin_by_id, :integer
|
add_column :ticket_articles, :origin_by_id, :integer
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class AddReplyTo < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :ticket_articles, :reply_to, :string, limit: 300
|
add_column :ticket_articles, :reply_to, :string, limit: 300
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FollowUpMerged < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Defines postmaster filter.',
|
title: 'Defines postmaster filter.',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SchedulerStatus < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
change_table :schedulers do |t|
|
change_table :schedulers do |t|
|
||||||
t.string :error_message, null: true
|
t.string :error_message, null: true
|
||||||
|
|
|
@ -2,7 +2,7 @@ class TriggerRecipientUpdate < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
['auto reply (on new tickets)', 'auto reply (on follow-up of tickets)'].each do |name|
|
['auto reply (on new tickets)', 'auto reply (on follow-up of tickets)'].each do |name|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ReplyToSenderFeature < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Sender based on Reply-To header',
|
title: 'Sender based on Reply-To header',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingDeliveryPermanentFailed < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
setting = Setting.find_by(name: '0900_postmaster_filter_bounce_check')
|
setting = Setting.find_by(name: '0900_postmaster_filter_bounce_check')
|
||||||
if setting
|
if setting
|
||||||
|
|
|
@ -2,7 +2,7 @@ class LdapMultiGroupMapping < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
# load existing LDAP config
|
# load existing LDAP config
|
||||||
ldap_config = Setting.get('ldap_config')
|
ldap_config = Setting.get('ldap_config')
|
||||||
|
|
|
@ -4,7 +4,7 @@ class ForeignKeys < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
# remove wrong plural of ID columns
|
# remove wrong plural of ID columns
|
||||||
ActiveRecord::Migration.rename_column :ticket_flags, :tickets_id, :ticket_id
|
ActiveRecord::Migration.rename_column :ticket_flags, :tickets_id, :ticket_id
|
||||||
|
|
|
@ -2,7 +2,7 @@ class EnhancedPermissions < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
change_column_null :groups_users, :user_id, false
|
change_column_null :groups_users, :user_id, false
|
||||||
change_column_null :groups_users, :group_id, false
|
change_column_null :groups_users, :group_id, false
|
||||||
|
|
|
@ -2,7 +2,7 @@ class TreeSelect < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
change_column :object_manager_attributes, :data_option, :text, limit: 800.kilobytes + 1, null: true
|
change_column :object_manager_attributes, :data_option, :text, limit: 800.kilobytes + 1, null: true
|
||||||
change_column :object_manager_attributes, :data_option_new, :text, limit: 800.kilobytes + 1, null: true
|
change_column :object_manager_attributes, :data_option_new, :text, limit: 800.kilobytes + 1, null: true
|
||||||
|
|
|
@ -2,7 +2,7 @@ class LocaleAddDirection < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :locales, :dir, :string, limit: 9, null: false, default: 'ltr'
|
add_column :locales, :dir, :string, limit: 9, null: false, default: 'ltr'
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FormGroupSelection < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
group = Group.where(active: true).first
|
group = Group.where(active: true).first
|
||||||
if !group
|
if !group
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ExchangeIntegration < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.set('import_backends', ['Import::Ldap', 'Import::Exchange'])
|
Setting.set('import_backends', ['Import::Ldap', 'Import::Exchange'])
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class OmniauthOffice365Setting < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Authentication via %s',
|
title: 'Authentication via %s',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class TicketZoomSetting2 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'ui_ticket_zoom_article_new_internal')
|
setting = Setting.find_by(name: 'ui_ticket_zoom_article_new_internal')
|
||||||
if setting
|
if setting
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ObjectManagerUserEmailOptional < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
ObjectManager::Attribute.add(
|
ObjectManager::Attribute.add(
|
||||||
force: true,
|
force: true,
|
||||||
|
|
|
@ -2,7 +2,7 @@ class UserEmailMultipleUse < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'User email for muliple users',
|
title: 'User email for muliple users',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class CleanupCtiLog < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Scheduler.create_if_not_exists(
|
Scheduler.create_if_not_exists(
|
||||||
name: 'Cleanup Cti::Log',
|
name: 'Cleanup Cti::Log',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingProxy < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Proxy Settings',
|
title: 'Proxy Settings',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class IdoitSupport < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'i-doit integration',
|
title: 'i-doit integration',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class AgendBasedSenderIssue1351 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
EmailAddress.all.each do |email_address|
|
EmailAddress.all.each do |email_address|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class OutOfOffice2 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
if !ActiveRecord::Base.connection.column_exists?(:overviews, :out_of_office)
|
if !ActiveRecord::Base.connection.column_exists?(:overviews, :out_of_office)
|
||||||
add_column :overviews, :out_of_office, :boolean, null: false, default: false
|
add_column :overviews, :out_of_office, :boolean, null: false, default: false
|
||||||
|
|
|
@ -2,7 +2,7 @@ class WeiboOauth2 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Authentication via %s',
|
title: 'Authentication via %s',
|
||||||
|
|
|
@ -2,10 +2,10 @@ class SettingSendNoAutoResponseRegExp < ActiveRecord::Migration[5.0]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
# improved domain name matching
|
# improved domain name matching
|
||||||
return if !Setting.find_by(name: 'send_no_auto_response_reg_exp')
|
return if !Setting.exists?(name: 'send_no_auto_response_reg_exp')
|
||||||
|
|
||||||
Setting.set('send_no_auto_response_reg_exp', '(mailer-daemon|postmaster|abuse|root|noreply|noreply.+?|no-reply|no-reply.+?)@.+?')
|
Setting.set('send_no_auto_response_reg_exp', '(mailer-daemon|postmaster|abuse|root|noreply|noreply.+?|no-reply|no-reply.+?)@.+?')
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class ChangeNoteCharLimitForUsersAndOrganizations < ActiveRecord::Migration[5.1]
|
class ChangeNoteCharLimitForUsersAndOrganizations < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup to avoid running the migration
|
# return if it's a new setup to avoid running the migration
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
change_column :organizations, :note, :string, limit: 5000
|
change_column :organizations, :note, :string, limit: 5000
|
||||||
change_column :users, :note, :string, limit: 5000
|
change_column :users, :note, :string, limit: 5000
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FixedStoreUpgradeRor45 < ActiveRecord::Migration[5.0]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Cache.clear
|
Cache.clear
|
||||||
[Macro, Taskbar, Calendar, Trigger, Channel, Job, PostmasterFilter, Report::Profile, Setting, Sla, Template].each do |class_name|
|
[Macro, Taskbar, Calendar, Trigger, Channel, Job, PostmasterFilter, Report::Profile, Setting, Sla, Template].each do |class_name|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class MonitIntegration < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Monit integration',
|
title: 'Monit integration',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class CheckMkIntegration2 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Check_MK integration',
|
title: 'Check_MK integration',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class LastOwnerUpdate2 < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
# reset assignment_timeout to prevent unwanted things happen
|
# reset assignment_timeout to prevent unwanted things happen
|
||||||
Group.all.each do |group|
|
Group.all.each do |group|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class EmailProcessCustomerSelectionBasedOnSenderRecipient < ActiveRecord::Migrat
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Customer selection based on sender and receiver list',
|
title: 'Customer selection based on sender and receiver list',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingEsPipeline < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Elasticsearch Pipeline Name',
|
title: 'Elasticsearch Pipeline Name',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingDefaultLocale2 < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'locale_default')
|
setting = Setting.find_by(name: 'locale_default')
|
||||||
if setting
|
if setting
|
||||||
|
|
|
@ -2,7 +2,7 @@ class PermissionUserPreferencesOutOfOffice < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Permission.create_if_not_exists(
|
Permission.create_if_not_exists(
|
||||||
name: 'user_preferences.out_of_office',
|
name: 'user_preferences.out_of_office',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class ChangeAuthorizationTokenSize < ActiveRecord::Migration[5.1]
|
class ChangeAuthorizationTokenSize < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup to avoid running the migration
|
# return if it's a new setup to avoid running the migration
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
change_column :authorizations, :token, :string, limit: 2500
|
change_column :authorizations, :token, :string, limit: 2500
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class ChangeExchangeExternalSyncIdentifier < ActiveRecord::Migration[5.1]
|
class ChangeExchangeExternalSyncIdentifier < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup to avoid running the migration
|
# return if it's a new setup to avoid running the migration
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
ExternalSync.where(
|
ExternalSync.where(
|
||||||
source: 'EWS::FolderContact'
|
source: 'EWS::FolderContact'
|
||||||
|
|
|
@ -2,7 +2,7 @@ class LdapSamaccountnameToUid < ActiveRecord::Migration[5.1]
|
||||||
|
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup to avoid running the migration
|
# return if it's a new setup to avoid running the migration
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Delayed::Job.enqueue MigrationJob::LdapSamaccountnameToUid.new
|
Delayed::Job.enqueue MigrationJob::LdapSamaccountnameToUid.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingTicketNumberIgnoreSystemIdSupport < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Ticket Number ignore system_id',
|
title: 'Ticket Number ignore system_id',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ChatAddIpCountry < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
add_column :chats, :block_ip, :string, limit: 5000, null: true
|
add_column :chats, :block_ip, :string, limit: 5000, null: true
|
||||||
add_column :chats, :block_country, :string, limit: 5000, null: true
|
add_column :chats, :block_country, :string, limit: 5000, null: true
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SidebarCustomerOpenTicketColored < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Open ticket indicator',
|
title: 'Open ticket indicator',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class CustomLdapLoginAttribute < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
return if no_change_needed?
|
return if no_change_needed?
|
||||||
|
|
||||||
perform_changes
|
perform_changes
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingAttachmentPreview < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Sidebar Attachments',
|
title: 'Sidebar Attachments',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingUserOrganizationSelectorWithEmail < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'User Organization Selector - email',
|
title: 'User Organization Selector - email',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class CheckForObjectAttributes < ActiveRecord::Migration[5.1]
|
class CheckForObjectAttributes < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
attributes.each do |attribute|
|
attributes.each do |attribute|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Issue1660FixTreeSelectConfigurations < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
return if attributes.blank?
|
return if attributes.blank?
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class CustomHtmlEmailCssFont < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'HTML Email CSS Font',
|
title: 'HTML Email CSS Font',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingTableGroupByShowCount < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Open ticket indicator',
|
title: 'Open ticket indicator',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Issue1905ExchangeLoginFromRemoteId < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
config = Import::Exchange.config
|
config = Import::Exchange.config
|
||||||
return if config.blank?
|
return if config.blank?
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SettingThirdPartyLinkAccountAtLogin < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Automatic account link on initial logon',
|
title: 'Automatic account link on initial logon',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Issue1977RemoveInvalidUserForeignKeys < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
OnlineNotification.joins('LEFT OUTER JOIN users ON online_notifications.user_id = users.id')
|
OnlineNotification.joins('LEFT OUTER JOIN users ON online_notifications.user_id = users.id')
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Issue1219ZhtwLocaleTypo < ActiveRecord::Migration[5.1]
|
||||||
APPLICABLE_VERSION = Gem::Version.new('2.5.0')
|
APPLICABLE_VERSION = Gem::Version.new('2.5.0')
|
||||||
|
|
||||||
def up
|
def up
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
return if CURRENT_VERSION < APPLICABLE_VERSION
|
return if CURRENT_VERSION < APPLICABLE_VERSION
|
||||||
|
|
||||||
if Locale.exists?(locale: 'zh-tw')
|
if Locale.exists?(locale: 'zh-tw')
|
||||||
|
@ -20,7 +20,7 @@ class Issue1219ZhtwLocaleTypo < ActiveRecord::Migration[5.1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
return if CURRENT_VERSION >= APPLICABLE_VERSION
|
return if CURRENT_VERSION >= APPLICABLE_VERSION
|
||||||
|
|
||||||
if Locale.exists?(locale: 'zj-tw')
|
if Locale.exists?(locale: 'zj-tw')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class TicketCreateTypesSettingIssue1987 < ActiveRecord::Migration[5.1]
|
class TicketCreateTypesSettingIssue1987 < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Default type for a new ticket',
|
title: 'Default type for a new ticket',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Issue2029SipgateIntegrationEnable < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
return if Setting.get('sipgate_config').present?
|
return if Setting.get('sipgate_config').present?
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class EmailForwardPrefixSettingIssue1730 < ActiveRecord::Migration[5.1]
|
class EmailForwardPrefixSettingIssue1730 < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Ticket Subject Forward',
|
title: 'Ticket Subject Forward',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class TicketLastContactBehavior < ActiveRecord::Migration[5.1]
|
class TicketLastContactBehavior < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Ticket Last Contact Behaviour',
|
title: 'Ticket Last Contact Behaviour',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class SmsSupport < ActiveRecord::Migration[5.1]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Permission.create_if_not_exists(
|
Permission.create_if_not_exists(
|
||||||
name: 'admin.channel_sms',
|
name: 'admin.channel_sms',
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Issue2035RecursiveTicketTrigger < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Recursive Ticket Triggers',
|
title: 'Recursive Ticket Triggers',
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue