From f5841a2fe37f956372430862416e8c5ba72423e1 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 3 Aug 2020 10:35:43 +0200 Subject: [PATCH] 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. --- .rubocop/cop/zammad/exists_condition.rb | 120 ++++++++++++++++++ .rubocop/default.yml | 1 + .rubocop/rubocop_zammad.rb | 1 + app/controllers/channels_email_controller.rb | 2 +- app/models/calendar.rb | 4 +- app/models/channel/driver/sms/twilio.rb | 2 +- app/models/channel/driver/twitter.rb | 6 +- app/models/channel/filter/identify_sender.rb | 2 +- .../filter/sender_is_system_address.rb | 2 +- app/models/email_address.rb | 2 +- app/models/tag/item.rb | 2 +- app/models/user.rb | 2 +- .../20150979000001_update_timestamps.rb | 2 +- ...160217000001_object_manager_update_user.rb | 2 +- .../20160921000001_permission_active.rb.rb | 2 +- ...01_organization_domain_based_assignment.rb | 2 +- ...17000001_job_unable_to_create_issue_432.rb | 2 +- ...00002_ticket_number_generator_issue_427.rb | 2 +- ...0003_store_config_name_update_issue_428.rb | 2 +- .../20161122000001_monitoring_issue_453.rb | 2 +- db/migrate/20161228000001_add_taskbar_meta.rb | 2 +- ..._object_manager_attribute_create_middle.rb | 2 +- ...0113000002_slack_group_config_issue_587.rb | 2 +- ...16000001_add_ticket_time_accounting_373.rb | 2 +- db/migrate/20170116000002_fixed_typos_622.rb | 2 +- ...01_unable_to_enable_time_accounting_633.rb | 2 +- .../20170119000001_login_email_length_650.rb | 2 +- ...001_ui_ticket_zoom_article_new_internal.rb | 2 +- .../20170123000002_fixed_translation.rb | 2 +- ...170126091128_application_secret_setting.rb | 2 +- ...0130000001_follow_up_possible_check_643.rb | 2 +- ...0001_remove_last_login_from_history_722.rb | 2 +- ...003_do_not_import_onw_notifications_731.rb | 2 +- ...07081400_ticket_state_priority_defaults.rb | 2 +- ..._online_browser_after_cors_csrf_changes.rb | 2 +- db/migrate/20170215000001_telegram_support.rb | 2 +- .../20170314000001_fixed_translation2.rb | 2 +- ...3000001_fixed_admin_user_permission_920.rb | 2 +- .../20170418000001_validate_agent_limit.rb | 2 +- db/migrate/20170419000001_ldap_support.rb | 2 +- .../20170419000002_overview_role_ids.rb | 2 +- ...170420000001_chat_increase_message_size.rb | 2 +- ...0170421000001_pretty_date_options_added.rb | 2 +- db/migrate/20170421110000_add_origin_by_id.rb | 2 +- db/migrate/20170426135500_add_reply_to.rb | 2 +- db/migrate/20170504144100_follow_up_merged.rb | 2 +- db/migrate/20170515000001_scheduler_status.rb | 2 +- ...20170516000001_trigger_recipient_update.rb | 2 +- .../20170525000001_reply_to_sender_feature.rb | 2 +- ...00002_setting_delivery_permanent_failed.rb | 2 +- ...20170529132120_ldap_multi_group_mapping.rb | 2 +- db/migrate/20170531144425_foreign_keys.rb | 2 +- .../20170608151442_enhanced_permissions.rb | 2 +- db/migrate/20170619000001_tree_select.rb | 2 +- .../20170626000001_locale_add_direction.rb | 2 +- .../20170628000001_form_group_selection.rb | 2 +- .../20170629000001_exchange_integration.rb | 2 +- ...170713000001_omniauth_office365_setting.rb | 2 +- .../20170713000002_ticket_zoom_setting2.rb | 2 +- ...0001_object_manager_user_email_optional.rb | 2 +- .../20170714000002_user_email_multiple_use.rb | 2 +- db/migrate/20170714000003_cleanup_cti_log.rb | 2 +- db/migrate/20170727000001_setting_proxy.rb | 2 +- db/migrate/20170816000001_idoit_support.rb | 2 +- ...822000001_agend_based_sender_issue_1351.rb | 2 +- db/migrate/20170910000002_out_of_office2.rb | 2 +- db/migrate/20170924054554_weibo_oauth2.rb | 2 +- ...1_setting_send_no_auto_response_reg_exp.rb | 4 +- ..._char_limit_for_users_and_organizations.rb | 2 +- ...171023000001_fixed_store_upgrade_ror_45.rb | 2 +- .../20171024000001_monit_integration.rb | 2 +- .../20171024000002_check_mk_integration2.rb | 2 +- .../20171102000001_last_owner_update2.rb | 2 +- ...mer_selection_based_on_sender_recipient.rb | 2 +- .../20171203000001_setting_es_pipeline.rb | 2 +- .../20171206000001_setting_default_locale2.rb | 2 +- ...rmission_user_preferences_out_of_office.rb | 2 +- ...3000001_change_authorization_token_size.rb | 2 +- ...hange_exchange_external_sync_identifier.rb | 2 +- ...180111000001_ldap_samaccountname_to_uid.rb | 2 +- ..._ticket_number_ignore_system_id_support.rb | 2 +- .../20180128000001_chat_add_ip_country.rb | 2 +- ...01_sidebar_customer_open_ticket_colored.rb | 2 +- ...80202000002_custom_ldap_login_attribute.rb | 2 +- ...180220000001_setting_attachment_preview.rb | 2 +- ...g_user_organization_selector_with_email.rb | 2 +- ...80220171219_check_for_object_attributes.rb | 2 +- ...sue_1660_fix_tree_select_configurations.rb | 2 +- ...180306084119_custom_html_email_css_font.rb | 2 +- ...00001_setting_table_group_by_show_count.rb | 2 +- ...ssue_1905_exchange_login_from_remote_id.rb | 2 +- ...tting_third_party_link_account_at_login.rb | 2 +- ...e_1977_remove_invalid_user_foreign_keys.rb | 2 +- ...80502015927_issue_1219_zhtw_locale_typo.rb | 4 +- ..._ticket_create_types_setting_issue_1987.rb | 2 +- ...01_issue2029_sipgate_integration_enable.rb | 2 +- ...email_forward_prefix_setting_issue_1730.rb | 2 +- ...0521141004_ticket_last_contact_behavior.rb | 2 +- db/migrate/20180524182518_sms_support.rb | 2 +- ...001_issue_2035_recursive_ticket_trigger.rb | 2 +- ...001_setting_add_ticket_auto_assignment2.rb | 2 +- ...611070839_add_ux_flow_next_up_to_macros.rb | 2 +- ...80622140531_sequencer_log_level_setting.rb | 2 +- ...020509_add_group_direction_to_overviews.rb | 2 +- ...x_double_domain_links_in_trigger_emails.rb | 2 +- ...xed_twitter_ticket_article_preferences7.rb | 2 +- db/migrate/20180809000001_cti_generic_api.rb | 2 +- ...00001_setting_delivery_temporary_failed.rb | 2 +- ...0911064647_issue_2140_reset_ldap_config.rb | 2 +- .../20180913000001_setting_add_system_bcc.rb | 2 +- ...13000002_permission_add_time_accounting.rb | 2 +- ...00000_setting_update_pretty_date_format.rb | 2 +- ...00_setting_add_sipgate_alternative_fqdn.rb | 2 +- db/migrate/20181017000001_cti_generic_api2.rb | 2 +- .../20181023163804_add_stats_backends.rb | 2 +- .../20181030000001_setting_add_placetel1.rb | 2 +- ...08123847_add_country_attribute_to_users.rb | 2 +- ...nt_max_size_in_mb_setting_lower_default.rb | 2 +- ...68_add_indices_to_histories_and_tickets.rb | 2 +- ...000_setting_add_email_full_quote_header.rb | 2 +- ...g_change_ticket_zoom_attachment_preview.rb | 2 +- ...20190208000001_setting_timezone_default.rb | 2 +- ...nager_attribute_date_remove_future_past.rb | 2 +- .../20190328000000_rename_locale_on_users.rb | 2 +- db/migrate/20190405000001_database_indexes.rb | 2 +- ...541_fix_notification_email_without_body.rb | 2 +- .../20190415000001_setting_es_multi_index.rb | 2 +- ..._setting_ticket_number_ignore_system_id.rb | 2 +- ...0190531180304_initialize_knowledge_base.rb | 2 +- ...190626000001_setting_update_karma_level.rb | 2 +- db/migrate/20190715141227_saml_auth.rb | 2 +- ...210244_issue_2641_kb_color_change_limit.rb | 2 +- ...20190718140450_forget_insecure_sessions.rb | 2 +- .../20190724000001_rename_reserved_words.rb | 2 +- ...01_setting_postmaster_send_reject_email.rb | 2 +- ...te_ticket_article_body_maxlength_change.rb | 2 +- ...903165443_issue_2595_gitlab_placeholder.rb | 2 +- ...53_issue_2867_footer_header_public_link.rb | 2 +- .../20191001090809_create_active_job_locks.rb | 2 +- ...3_issue_2608_missing_trigger_permission.rb | 2 +- ...49_issue_2460_fix_corrupted_twitter_ids.rb | 2 +- ...1428_issue_2715_fix_broken_twitter_urls.rb | 2 +- ...0_active_job_lock_cleanup_job_scheduler.rb | 2 +- db/migrate/20200121000001_smime_support.rb | 2 +- .../20200205000001_chat_add_allow_website.rb | 2 +- .../20200401000001_service_now_config.rb | 2 +- ...0200419204445_setting_websocket_backend.rb | 2 +- ...ication_migration_cleanup_job_scheduler.rb | 2 +- ...aintenance_checkmk_wordings_on_settings.rb | 2 +- ...9094556_issue_3110_service_now_provider.rb | 2 +- ...1_issue_3123_external_sync_ticket_merge.rb | 2 +- lib/app_version.rb | 2 +- lib/facebook.rb | 2 +- lib/import/otrs/history.rb | 2 +- lib/telegram.rb | 2 +- lib/twitter_sync.rb | 4 +- spec/lib/import/otrs/history_examples.rb | 2 +- spec/support/system_init_done.rb | 6 +- 158 files changed, 285 insertions(+), 163 deletions(-) create mode 100644 .rubocop/cop/zammad/exists_condition.rb create mode 100644 .rubocop/rubocop_zammad.rb diff --git a/.rubocop/cop/zammad/exists_condition.rb b/.rubocop/cop/zammad/exists_condition.rb new file mode 100644 index 000000000..b66b10396 --- /dev/null +++ b/.rubocop/cop/zammad/exists_condition.rb @@ -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 `%s` instead of `%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 diff --git a/.rubocop/default.yml b/.rubocop/default.yml index bc418e1d3..476aa0def 100644 --- a/.rubocop/default.yml +++ b/.rubocop/default.yml @@ -5,6 +5,7 @@ require: - rubocop-performance - rubocop-rails - rubocop-rspec + - ./rubocop_zammad.rb inherit_from: - todo.yml diff --git a/.rubocop/rubocop_zammad.rb b/.rubocop/rubocop_zammad.rb new file mode 100644 index 000000000..d34a735a7 --- /dev/null +++ b/.rubocop/rubocop_zammad.rb @@ -0,0 +1 @@ +require_relative 'cop/zammad/exists_condition' diff --git a/app/controllers/channels_email_controller.rb b/app/controllers/channels_email_controller.rb index 74ec24ea5..708151895 100644 --- a/app/controllers/channels_email_controller.rb +++ b/app/controllers/channels_email_controller.rb @@ -31,7 +31,7 @@ class ChannelsEmailController < ApplicationController email_address_ids.push email_address.id 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 end end diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 31f130060..5b866cd94 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -360,7 +360,7 @@ returns # check if min one is set to default true def min_one_check - if !Calendar.find_by(default: true) + if !Calendar.exists?(default: true) first = Calendar.order(:created_at, :id).limit(1).first return true if !first @@ -376,7 +376,7 @@ returns sla.save! next end - if !Calendar.find_by(id: sla.calendar_id) + if !Calendar.exists?(id: sla.calendar_id) sla.calendar_id = default_calendar.id sla.save! end diff --git a/app/models/channel/driver/sms/twilio.rb b/app/models/channel/driver/sms/twilio.rb index 8f22cb6da..1ba4a7a80 100644 --- a/app/models/channel/driver/sms/twilio.rb +++ b/app/models/channel/driver/sms/twilio.rb @@ -33,7 +33,7 @@ class Channel::Driver::Sms::Twilio Rails.logger.info "Receiving SMS frim recipient #{attr[:From]}" # 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] end diff --git a/app/models/channel/driver/twitter.rb b/app/models/channel/driver/twitter.rb index d554a8ae6..2c602ebe9 100644 --- a/app/models/channel/driver/twitter.rb +++ b/app/models/channel/driver/twitter.rb @@ -186,7 +186,7 @@ returns end 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) @client.to_group(tweet, search[:group_id], @channel) @@ -202,7 +202,7 @@ returns event_time = Time.zone.now sleep 4 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}" } return true end @@ -215,7 +215,7 @@ returns sleep sleep_time 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}" } return true end diff --git a/app/models/channel/filter/identify_sender.rb b/app/models/channel/filter/identify_sender.rb index 022b6cb08..a1b7499dc 100644 --- a/app/models/channel/filter/identify_sender.rb +++ b/app/models/channel/filter/identify_sender.rb @@ -35,7 +35,7 @@ module Channel::Filter::IdentifySender items.each do |item| # 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( login: item.address, diff --git a/app/models/channel/filter/sender_is_system_address.rb b/app/models/channel/filter/sender_is_system_address.rb index 4a6ee37d6..44324abd3 100644 --- a/app/models/channel/filter/sender_is_system_address.rb +++ b/app/models/channel/filter/sender_is_system_address.rb @@ -19,7 +19,7 @@ module Channel::Filter::SenderIsSystemAddress items = mail[form].addrs 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-article-sender'.to_sym] = 'Agent' diff --git a/app/models/email_address.rb b/app/models/email_address.rb index 232fada0e..060268c5f 100644 --- a/app/models/email_address.rb +++ b/app/models/email_address.rb @@ -63,7 +63,7 @@ check and if channel not exists reset configured channels for email addresses def check_if_channel_exists_set_inactive # 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 return true end diff --git a/app/models/tag/item.rb b/app/models/tag/item.rb index 94b1c25d8..fc3aeb9e3 100644 --- a/app/models/tag/item.rb +++ b/app/models/tag/item.rb @@ -49,7 +49,7 @@ Tag::Item.rename( Tag.where(tag_item_id: old_tag_item.id).each do |tag| # 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_object_id: tag.tag_object_id, o_id: tag.o_id, diff --git a/app/models/user.rb b/app/models/user.rb index 03da4f9d3..317a94da7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 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 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 end diff --git a/db/migrate/20150979000001_update_timestamps.rb b/db/migrate/20150979000001_update_timestamps.rb index 0fdefb07c..5b2b19006 100644 --- a/db/migrate/20150979000001_update_timestamps.rb +++ b/db/migrate/20150979000001_update_timestamps.rb @@ -1,7 +1,7 @@ class UpdateTimestamps < ActiveRecord::Migration[4.2] def up # 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 Models.all.each_value do |value| diff --git a/db/migrate/20160217000001_object_manager_update_user.rb b/db/migrate/20160217000001_object_manager_update_user.rb index a5ad46081..bd151a6d6 100644 --- a/db/migrate/20160217000001_object_manager_update_user.rb +++ b/db/migrate/20160217000001_object_manager_update_user.rb @@ -2,7 +2,7 @@ class ObjectManagerUpdateUser < ActiveRecord::Migration[4.2] def up # 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 ObjectManager::Attribute.add( diff --git a/db/migrate/20160921000001_permission_active.rb.rb b/db/migrate/20160921000001_permission_active.rb.rb index d54f70803..e8bcf683f 100644 --- a/db/migrate/20160921000001_permission_active.rb.rb +++ b/db/migrate/20160921000001_permission_active.rb.rb @@ -1,7 +1,7 @@ class PermissionActive < ActiveRecord::Migration[4.2] def up # 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 diff --git a/db/migrate/20161112000001_organization_domain_based_assignment.rb b/db/migrate/20161112000001_organization_domain_based_assignment.rb index f243cb352..cd17ae6e9 100644 --- a/db/migrate/20161112000001_organization_domain_based_assignment.rb +++ b/db/migrate/20161112000001_organization_domain_based_assignment.rb @@ -1,7 +1,7 @@ class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2] def up # 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_assignment, :boolean, null: false, default: false diff --git a/db/migrate/20161117000001_job_unable_to_create_issue_432.rb b/db/migrate/20161117000001_job_unable_to_create_issue_432.rb index 4546ac018..56411cda1 100644 --- a/db/migrate/20161117000001_job_unable_to_create_issue_432.rb +++ b/db/migrate/20161117000001_job_unable_to_create_issue_432.rb @@ -1,7 +1,7 @@ class JobUnableToCreateIssue432 < ActiveRecord::Migration[4.2] def up # 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| t.change :timeplan, :string, limit: 2500 diff --git a/db/migrate/20161117000002_ticket_number_generator_issue_427.rb b/db/migrate/20161117000002_ticket_number_generator_issue_427.rb index 22f87c03a..cd6e07a59 100644 --- a/db/migrate/20161117000002_ticket_number_generator_issue_427.rb +++ b/db/migrate/20161117000002_ticket_number_generator_issue_427.rb @@ -1,7 +1,7 @@ class TicketNumberGeneratorIssue427 < ActiveRecord::Migration[4.2] def up # 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.preferences = { diff --git a/db/migrate/20161117000003_store_config_name_update_issue_428.rb b/db/migrate/20161117000003_store_config_name_update_issue_428.rb index 52cd9f3b2..6fc2c40e0 100644 --- a/db/migrate/20161117000003_store_config_name_update_issue_428.rb +++ b/db/migrate/20161117000003_store_config_name_update_issue_428.rb @@ -1,7 +1,7 @@ class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration[4.2] def up # 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') return if !setting diff --git a/db/migrate/20161122000001_monitoring_issue_453.rb b/db/migrate/20161122000001_monitoring_issue_453.rb index bebbfb817..08348f8d7 100644 --- a/db/migrate/20161122000001_monitoring_issue_453.rb +++ b/db/migrate/20161122000001_monitoring_issue_453.rb @@ -1,7 +1,7 @@ class MonitoringIssue453 < ActiveRecord::Migration[4.2] def up # 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( title: 'Monitoring Token', diff --git a/db/migrate/20161228000001_add_taskbar_meta.rb b/db/migrate/20161228000001_add_taskbar_meta.rb index a20ef07e7..1eb2a74d8 100644 --- a/db/migrate/20161228000001_add_taskbar_meta.rb +++ b/db/migrate/20161228000001_add_taskbar_meta.rb @@ -1,7 +1,7 @@ class AddTaskbarMeta < ActiveRecord::Migration[4.2] def up # 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_index :taskbars, [:key] diff --git a/db/migrate/20170113000001_object_manager_attribute_create_middle.rb b/db/migrate/20170113000001_object_manager_attribute_create_middle.rb index 7088bc2e7..6afe873eb 100644 --- a/db/migrate/20170113000001_object_manager_attribute_create_middle.rb +++ b/db/migrate/20170113000001_object_manager_attribute_create_middle.rb @@ -1,7 +1,7 @@ class ObjectManagerAttributeCreateMiddle < ActiveRecord::Migration[4.2] def up # 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| next if attribute.name == 'tags' diff --git a/db/migrate/20170113000002_slack_group_config_issue_587.rb b/db/migrate/20170113000002_slack_group_config_issue_587.rb index 23938fe93..9712d7a90 100644 --- a/db/migrate/20170113000002_slack_group_config_issue_587.rb +++ b/db/migrate/20170113000002_slack_group_config_issue_587.rb @@ -2,7 +2,7 @@ class SlackGroupConfigIssue587 < ActiveRecord::Migration[4.2] def up # 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') return if !setting diff --git a/db/migrate/20170116000001_add_ticket_time_accounting_373.rb b/db/migrate/20170116000001_add_ticket_time_accounting_373.rb index e2b6adc3c..c63958e31 100644 --- a/db/migrate/20170116000001_add_ticket_time_accounting_373.rb +++ b/db/migrate/20170116000001_add_ticket_time_accounting_373.rb @@ -2,7 +2,7 @@ class AddTicketTimeAccounting373 < ActiveRecord::Migration[4.2] def up # 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 create_table :ticket_time_accountings do |t| diff --git a/db/migrate/20170116000002_fixed_typos_622.rb b/db/migrate/20170116000002_fixed_typos_622.rb index 438fd606d..992a3a790 100644 --- a/db/migrate/20170116000002_fixed_typos_622.rb +++ b/db/migrate/20170116000002_fixed_typos_622.rb @@ -2,7 +2,7 @@ class FixedTypos622 < ActiveRecord::Migration[4.2] def up # 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') return if !setting diff --git a/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb b/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb index c05ba0828..37d5da470 100644 --- a/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb +++ b/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb @@ -2,7 +2,7 @@ class UnableToEnableTimeAccounting633 < ActiveRecord::Migration[4.2] def up # 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( title: 'Time Accounting', diff --git a/db/migrate/20170119000001_login_email_length_650.rb b/db/migrate/20170119000001_login_email_length_650.rb index 8dde12b99..71ef80b1d 100644 --- a/db/migrate/20170119000001_login_email_length_650.rb +++ b/db/migrate/20170119000001_login_email_length_650.rb @@ -2,7 +2,7 @@ class LoginEmailLength650 < ActiveRecord::Migration[4.2] def up # 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, :email, :string, limit: 255) diff --git a/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb b/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb index d29e606c9..f51a79e2a 100644 --- a/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb +++ b/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb @@ -2,7 +2,7 @@ class UiTicketZoomArticleNewInternal < ActiveRecord::Migration[4.2] def up # 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( title: 'Define default visibility of new a new article', diff --git a/db/migrate/20170123000002_fixed_translation.rb b/db/migrate/20170123000002_fixed_translation.rb index 4acde1979..014731d16 100644 --- a/db/migrate/20170123000002_fixed_translation.rb +++ b/db/migrate/20170123000002_fixed_translation.rb @@ -2,7 +2,7 @@ class FixedTranslation < ActiveRecord::Migration[4.2] def up # 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 = [ { diff --git a/db/migrate/20170126091128_application_secret_setting.rb b/db/migrate/20170126091128_application_secret_setting.rb index 0fbd50075..9c703ede1 100644 --- a/db/migrate/20170126091128_application_secret_setting.rb +++ b/db/migrate/20170126091128_application_secret_setting.rb @@ -2,7 +2,7 @@ class ApplicationSecretSetting < ActiveRecord::Migration[4.2] def up # 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( title: 'Application secret', diff --git a/db/migrate/20170130000001_follow_up_possible_check_643.rb b/db/migrate/20170130000001_follow_up_possible_check_643.rb index 87d266552..6ca22855e 100644 --- a/db/migrate/20170130000001_follow_up_possible_check_643.rb +++ b/db/migrate/20170130000001_follow_up_possible_check_643.rb @@ -2,7 +2,7 @@ class FollowUpPossibleCheck643 < ActiveRecord::Migration[4.2] def up # 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( title: 'Define postmaster filter.', diff --git a/db/migrate/20170203000001_remove_last_login_from_history_722.rb b/db/migrate/20170203000001_remove_last_login_from_history_722.rb index 152d74cb6..fe84861a4 100644 --- a/db/migrate/20170203000001_remove_last_login_from_history_722.rb +++ b/db/migrate/20170203000001_remove_last_login_from_history_722.rb @@ -2,7 +2,7 @@ class RemoveLastLoginFromHistory722 < ActiveRecord::Migration[4.2] def up # 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') return if !history_object diff --git a/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb b/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb index 3e6198468..62058068f 100644 --- a/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb +++ b/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb @@ -2,7 +2,7 @@ class DoNotImportOnwNotifications731 < ActiveRecord::Migration[4.2] def up # 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( title: 'Define postmaster filter.', diff --git a/db/migrate/20170207081400_ticket_state_priority_defaults.rb b/db/migrate/20170207081400_ticket_state_priority_defaults.rb index 7e976ab8f..7e25748c6 100644 --- a/db/migrate/20170207081400_ticket_state_priority_defaults.rb +++ b/db/migrate/20170207081400_ticket_state_priority_defaults.rb @@ -2,7 +2,7 @@ class TicketStatePriorityDefaults < ActiveRecord::Migration[4.2] def up # 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_index :ticket_states, :default_create diff --git a/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb b/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb index f082be45b..298b3a716 100644 --- a/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb +++ b/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb @@ -2,7 +2,7 @@ class ReloadOnlineBrowserAfterCorsCsrfChanges < ActiveRecord::Migration[4.2] def up # 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') end diff --git a/db/migrate/20170215000001_telegram_support.rb b/db/migrate/20170215000001_telegram_support.rb index 9d4da9dba..ab733223e 100644 --- a/db/migrate/20170215000001_telegram_support.rb +++ b/db/migrate/20170215000001_telegram_support.rb @@ -2,7 +2,7 @@ class TelegramSupport < ActiveRecord::Migration[4.2] def up # 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( name: 'admin.channel_telegram', diff --git a/db/migrate/20170314000001_fixed_translation2.rb b/db/migrate/20170314000001_fixed_translation2.rb index e3b5eaaa8..e20e9f85e 100644 --- a/db/migrate/20170314000001_fixed_translation2.rb +++ b/db/migrate/20170314000001_fixed_translation2.rb @@ -2,7 +2,7 @@ class FixedTranslation2 < ActiveRecord::Migration[4.2] def up # 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 = [ { diff --git a/db/migrate/20170403000001_fixed_admin_user_permission_920.rb b/db/migrate/20170403000001_fixed_admin_user_permission_920.rb index 4ca888bce..21a43a8ac 100644 --- a/db/migrate/20170403000001_fixed_admin_user_permission_920.rb +++ b/db/migrate/20170403000001_fixed_admin_user_permission_920.rb @@ -2,7 +2,7 @@ class FixedAdminUserPermission920 < ActiveRecord::Migration[4.2] def up # 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( force: true, diff --git a/db/migrate/20170418000001_validate_agent_limit.rb b/db/migrate/20170418000001_validate_agent_limit.rb index 6c6f4fd40..1caf48eef 100644 --- a/db/migrate/20170418000001_validate_agent_limit.rb +++ b/db/migrate/20170418000001_validate_agent_limit.rb @@ -1,7 +1,7 @@ class ValidateAgentLimit < ActiveRecord::Migration[4.2] def up # 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( title: 'Set limit of agents', diff --git a/db/migrate/20170419000001_ldap_support.rb b/db/migrate/20170419000001_ldap_support.rb index c460e8757..97d3f69f8 100644 --- a/db/migrate/20170419000001_ldap_support.rb +++ b/db/migrate/20170419000001_ldap_support.rb @@ -2,7 +2,7 @@ class LdapSupport < ActiveRecord::Migration[4.2] def up # 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' create_table :import_jobs do |t| diff --git a/db/migrate/20170419000002_overview_role_ids.rb b/db/migrate/20170419000002_overview_role_ids.rb index 124f8c019..5a8f625a3 100644 --- a/db/migrate/20170419000002_overview_role_ids.rb +++ b/db/migrate/20170419000002_overview_role_ids.rb @@ -2,7 +2,7 @@ class OverviewRoleIds < ActiveRecord::Migration[4.2] def up # 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| t.integer :overview_id diff --git a/db/migrate/20170420000001_chat_increase_message_size.rb b/db/migrate/20170420000001_chat_increase_message_size.rb index 382bdfa6d..4df90947d 100644 --- a/db/migrate/20170420000001_chat_increase_message_size.rb +++ b/db/migrate/20170420000001_chat_increase_message_size.rb @@ -2,7 +2,7 @@ class ChatIncreaseMessageSize < ActiveRecord::Migration[4.2] def up # 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 end diff --git a/db/migrate/20170421000001_pretty_date_options_added.rb b/db/migrate/20170421000001_pretty_date_options_added.rb index 3ed947a66..593c22b92 100644 --- a/db/migrate/20170421000001_pretty_date_options_added.rb +++ b/db/migrate/20170421000001_pretty_date_options_added.rb @@ -2,7 +2,7 @@ class PrettyDateOptionsAdded < ActiveRecord::Migration[4.2] def up # 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( title: 'Pretty Date', diff --git a/db/migrate/20170421110000_add_origin_by_id.rb b/db/migrate/20170421110000_add_origin_by_id.rb index c010e9cca..520d87496 100644 --- a/db/migrate/20170421110000_add_origin_by_id.rb +++ b/db/migrate/20170421110000_add_origin_by_id.rb @@ -2,7 +2,7 @@ class AddOriginById < ActiveRecord::Migration[4.2] def up # 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 end diff --git a/db/migrate/20170426135500_add_reply_to.rb b/db/migrate/20170426135500_add_reply_to.rb index 86cfec2fb..d59db438d 100644 --- a/db/migrate/20170426135500_add_reply_to.rb +++ b/db/migrate/20170426135500_add_reply_to.rb @@ -2,7 +2,7 @@ class AddReplyTo < ActiveRecord::Migration[4.2] def up # 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 end diff --git a/db/migrate/20170504144100_follow_up_merged.rb b/db/migrate/20170504144100_follow_up_merged.rb index e8056f295..3968506dc 100644 --- a/db/migrate/20170504144100_follow_up_merged.rb +++ b/db/migrate/20170504144100_follow_up_merged.rb @@ -2,7 +2,7 @@ class FollowUpMerged < ActiveRecord::Migration[4.2] def up # 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( title: 'Defines postmaster filter.', diff --git a/db/migrate/20170515000001_scheduler_status.rb b/db/migrate/20170515000001_scheduler_status.rb index dcaa8ef87..81f02fcb2 100644 --- a/db/migrate/20170515000001_scheduler_status.rb +++ b/db/migrate/20170515000001_scheduler_status.rb @@ -2,7 +2,7 @@ class SchedulerStatus < ActiveRecord::Migration[4.2] def up # 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| t.string :error_message, null: true diff --git a/db/migrate/20170516000001_trigger_recipient_update.rb b/db/migrate/20170516000001_trigger_recipient_update.rb index 2df46112b..01e33e53e 100644 --- a/db/migrate/20170516000001_trigger_recipient_update.rb +++ b/db/migrate/20170516000001_trigger_recipient_update.rb @@ -2,7 +2,7 @@ class TriggerRecipientUpdate < ActiveRecord::Migration[4.2] def up # 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| diff --git a/db/migrate/20170525000001_reply_to_sender_feature.rb b/db/migrate/20170525000001_reply_to_sender_feature.rb index 72ed3a9d1..abf26894e 100644 --- a/db/migrate/20170525000001_reply_to_sender_feature.rb +++ b/db/migrate/20170525000001_reply_to_sender_feature.rb @@ -2,7 +2,7 @@ class ReplyToSenderFeature < ActiveRecord::Migration[4.2] def up # 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( title: 'Sender based on Reply-To header', diff --git a/db/migrate/20170529000002_setting_delivery_permanent_failed.rb b/db/migrate/20170529000002_setting_delivery_permanent_failed.rb index dbc39dea1..29160617b 100644 --- a/db/migrate/20170529000002_setting_delivery_permanent_failed.rb +++ b/db/migrate/20170529000002_setting_delivery_permanent_failed.rb @@ -2,7 +2,7 @@ class SettingDeliveryPermanentFailed < ActiveRecord::Migration[4.2] def up # 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') if setting diff --git a/db/migrate/20170529132120_ldap_multi_group_mapping.rb b/db/migrate/20170529132120_ldap_multi_group_mapping.rb index ae745dbee..f0d711611 100644 --- a/db/migrate/20170529132120_ldap_multi_group_mapping.rb +++ b/db/migrate/20170529132120_ldap_multi_group_mapping.rb @@ -2,7 +2,7 @@ class LdapMultiGroupMapping < ActiveRecord::Migration[4.2] def up # 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 ldap_config = Setting.get('ldap_config') diff --git a/db/migrate/20170531144425_foreign_keys.rb b/db/migrate/20170531144425_foreign_keys.rb index cd124e74d..85db68367 100644 --- a/db/migrate/20170531144425_foreign_keys.rb +++ b/db/migrate/20170531144425_foreign_keys.rb @@ -4,7 +4,7 @@ class ForeignKeys < ActiveRecord::Migration[4.2] def change # 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 ActiveRecord::Migration.rename_column :ticket_flags, :tickets_id, :ticket_id diff --git a/db/migrate/20170608151442_enhanced_permissions.rb b/db/migrate/20170608151442_enhanced_permissions.rb index b47a1daeb..b3d1c83e2 100644 --- a/db/migrate/20170608151442_enhanced_permissions.rb +++ b/db/migrate/20170608151442_enhanced_permissions.rb @@ -2,7 +2,7 @@ class EnhancedPermissions < ActiveRecord::Migration[4.2] def up # 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, :group_id, false diff --git a/db/migrate/20170619000001_tree_select.rb b/db/migrate/20170619000001_tree_select.rb index 8416568ac..9c8ab0b32 100644 --- a/db/migrate/20170619000001_tree_select.rb +++ b/db/migrate/20170619000001_tree_select.rb @@ -2,7 +2,7 @@ class TreeSelect < ActiveRecord::Migration[4.2] def up # 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_new, :text, limit: 800.kilobytes + 1, null: true diff --git a/db/migrate/20170626000001_locale_add_direction.rb b/db/migrate/20170626000001_locale_add_direction.rb index 5302ff115..36ce63991 100644 --- a/db/migrate/20170626000001_locale_add_direction.rb +++ b/db/migrate/20170626000001_locale_add_direction.rb @@ -2,7 +2,7 @@ class LocaleAddDirection < ActiveRecord::Migration[4.2] def up # 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' end diff --git a/db/migrate/20170628000001_form_group_selection.rb b/db/migrate/20170628000001_form_group_selection.rb index ed2e7e367..fe15467b8 100644 --- a/db/migrate/20170628000001_form_group_selection.rb +++ b/db/migrate/20170628000001_form_group_selection.rb @@ -2,7 +2,7 @@ class FormGroupSelection < ActiveRecord::Migration[4.2] def up # 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 if !group diff --git a/db/migrate/20170629000001_exchange_integration.rb b/db/migrate/20170629000001_exchange_integration.rb index 2d715a750..aba8bf411 100644 --- a/db/migrate/20170629000001_exchange_integration.rb +++ b/db/migrate/20170629000001_exchange_integration.rb @@ -2,7 +2,7 @@ class ExchangeIntegration < ActiveRecord::Migration[4.2] def up # 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']) diff --git a/db/migrate/20170713000001_omniauth_office365_setting.rb b/db/migrate/20170713000001_omniauth_office365_setting.rb index 553aeafd8..53e1038ff 100644 --- a/db/migrate/20170713000001_omniauth_office365_setting.rb +++ b/db/migrate/20170713000001_omniauth_office365_setting.rb @@ -2,7 +2,7 @@ class OmniauthOffice365Setting < ActiveRecord::Migration[4.2] def up # 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( title: 'Authentication via %s', diff --git a/db/migrate/20170713000002_ticket_zoom_setting2.rb b/db/migrate/20170713000002_ticket_zoom_setting2.rb index ec397a5d8..b7355ea57 100644 --- a/db/migrate/20170713000002_ticket_zoom_setting2.rb +++ b/db/migrate/20170713000002_ticket_zoom_setting2.rb @@ -2,7 +2,7 @@ class TicketZoomSetting2 < ActiveRecord::Migration[4.2] def up # 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') if setting diff --git a/db/migrate/20170714000001_object_manager_user_email_optional.rb b/db/migrate/20170714000001_object_manager_user_email_optional.rb index 7733b2c25..0a3c53c5e 100644 --- a/db/migrate/20170714000001_object_manager_user_email_optional.rb +++ b/db/migrate/20170714000001_object_manager_user_email_optional.rb @@ -2,7 +2,7 @@ class ObjectManagerUserEmailOptional < ActiveRecord::Migration[4.2] def up # 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( force: true, diff --git a/db/migrate/20170714000002_user_email_multiple_use.rb b/db/migrate/20170714000002_user_email_multiple_use.rb index da0323db0..69f0f4c1f 100644 --- a/db/migrate/20170714000002_user_email_multiple_use.rb +++ b/db/migrate/20170714000002_user_email_multiple_use.rb @@ -2,7 +2,7 @@ class UserEmailMultipleUse < ActiveRecord::Migration[4.2] def up # 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( title: 'User email for muliple users', diff --git a/db/migrate/20170714000003_cleanup_cti_log.rb b/db/migrate/20170714000003_cleanup_cti_log.rb index 726c4463b..fb790b3cc 100644 --- a/db/migrate/20170714000003_cleanup_cti_log.rb +++ b/db/migrate/20170714000003_cleanup_cti_log.rb @@ -2,7 +2,7 @@ class CleanupCtiLog < ActiveRecord::Migration[4.2] def up # 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( name: 'Cleanup Cti::Log', diff --git a/db/migrate/20170727000001_setting_proxy.rb b/db/migrate/20170727000001_setting_proxy.rb index 328951274..0874d1a28 100644 --- a/db/migrate/20170727000001_setting_proxy.rb +++ b/db/migrate/20170727000001_setting_proxy.rb @@ -2,7 +2,7 @@ class SettingProxy < ActiveRecord::Migration[4.2] def up # 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( title: 'Proxy Settings', diff --git a/db/migrate/20170816000001_idoit_support.rb b/db/migrate/20170816000001_idoit_support.rb index 66b6bc48e..41cb2a732 100644 --- a/db/migrate/20170816000001_idoit_support.rb +++ b/db/migrate/20170816000001_idoit_support.rb @@ -2,7 +2,7 @@ class IdoitSupport < ActiveRecord::Migration[4.2] def up # 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( title: 'i-doit integration', diff --git a/db/migrate/20170822000001_agend_based_sender_issue_1351.rb b/db/migrate/20170822000001_agend_based_sender_issue_1351.rb index 784ccdd2b..c57e39dec 100644 --- a/db/migrate/20170822000001_agend_based_sender_issue_1351.rb +++ b/db/migrate/20170822000001_agend_based_sender_issue_1351.rb @@ -2,7 +2,7 @@ class AgendBasedSenderIssue1351 < ActiveRecord::Migration[4.2] def up # 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| diff --git a/db/migrate/20170910000002_out_of_office2.rb b/db/migrate/20170910000002_out_of_office2.rb index 0796c3479..4f5a3ef67 100644 --- a/db/migrate/20170910000002_out_of_office2.rb +++ b/db/migrate/20170910000002_out_of_office2.rb @@ -2,7 +2,7 @@ class OutOfOffice2 < ActiveRecord::Migration[4.2] def up # 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) add_column :overviews, :out_of_office, :boolean, null: false, default: false diff --git a/db/migrate/20170924054554_weibo_oauth2.rb b/db/migrate/20170924054554_weibo_oauth2.rb index 02ecad20f..af71d06c1 100644 --- a/db/migrate/20170924054554_weibo_oauth2.rb +++ b/db/migrate/20170924054554_weibo_oauth2.rb @@ -2,7 +2,7 @@ class WeiboOauth2 < ActiveRecord::Migration[4.2] def up # 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( title: 'Authentication via %s', diff --git a/db/migrate/20170927000001_setting_send_no_auto_response_reg_exp.rb b/db/migrate/20170927000001_setting_send_no_auto_response_reg_exp.rb index a4d280ca9..5f6c59604 100644 --- a/db/migrate/20170927000001_setting_send_no_auto_response_reg_exp.rb +++ b/db/migrate/20170927000001_setting_send_no_auto_response_reg_exp.rb @@ -2,10 +2,10 @@ class SettingSendNoAutoResponseRegExp < ActiveRecord::Migration[5.0] def up # 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 - 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.+?)@.+?') end diff --git a/db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb b/db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb index 91d64f89b..a1e37143f 100644 --- a/db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb +++ b/db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb @@ -1,7 +1,7 @@ class ChangeNoteCharLimitForUsersAndOrganizations < ActiveRecord::Migration[5.1] def up # 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 :users, :note, :string, limit: 5000 diff --git a/db/migrate/20171023000001_fixed_store_upgrade_ror_45.rb b/db/migrate/20171023000001_fixed_store_upgrade_ror_45.rb index e41354055..83212d37d 100644 --- a/db/migrate/20171023000001_fixed_store_upgrade_ror_45.rb +++ b/db/migrate/20171023000001_fixed_store_upgrade_ror_45.rb @@ -2,7 +2,7 @@ class FixedStoreUpgradeRor45 < ActiveRecord::Migration[5.0] def up # 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 [Macro, Taskbar, Calendar, Trigger, Channel, Job, PostmasterFilter, Report::Profile, Setting, Sla, Template].each do |class_name| diff --git a/db/migrate/20171024000001_monit_integration.rb b/db/migrate/20171024000001_monit_integration.rb index 56d22522a..ae9dbfed0 100644 --- a/db/migrate/20171024000001_monit_integration.rb +++ b/db/migrate/20171024000001_monit_integration.rb @@ -2,7 +2,7 @@ class MonitIntegration < ActiveRecord::Migration[4.2] def up # 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( title: 'Monit integration', diff --git a/db/migrate/20171024000002_check_mk_integration2.rb b/db/migrate/20171024000002_check_mk_integration2.rb index a8ad18669..fb8e2b01b 100644 --- a/db/migrate/20171024000002_check_mk_integration2.rb +++ b/db/migrate/20171024000002_check_mk_integration2.rb @@ -2,7 +2,7 @@ class CheckMkIntegration2 < ActiveRecord::Migration[4.2] def up # 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( title: 'Check_MK integration', diff --git a/db/migrate/20171102000001_last_owner_update2.rb b/db/migrate/20171102000001_last_owner_update2.rb index a0d402c17..968b54184 100644 --- a/db/migrate/20171102000001_last_owner_update2.rb +++ b/db/migrate/20171102000001_last_owner_update2.rb @@ -2,7 +2,7 @@ class LastOwnerUpdate2 < ActiveRecord::Migration[5.1] def up # 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 Group.all.each do |group| diff --git a/db/migrate/20171123000001_email_process_customer_selection_based_on_sender_recipient.rb b/db/migrate/20171123000001_email_process_customer_selection_based_on_sender_recipient.rb index 89010f620..9d74a0cb5 100644 --- a/db/migrate/20171123000001_email_process_customer_selection_based_on_sender_recipient.rb +++ b/db/migrate/20171123000001_email_process_customer_selection_based_on_sender_recipient.rb @@ -2,7 +2,7 @@ class EmailProcessCustomerSelectionBasedOnSenderRecipient < ActiveRecord::Migrat def up # 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( title: 'Customer selection based on sender and receiver list', diff --git a/db/migrate/20171203000001_setting_es_pipeline.rb b/db/migrate/20171203000001_setting_es_pipeline.rb index ab4813f2a..ec774098b 100644 --- a/db/migrate/20171203000001_setting_es_pipeline.rb +++ b/db/migrate/20171203000001_setting_es_pipeline.rb @@ -2,7 +2,7 @@ class SettingEsPipeline < ActiveRecord::Migration[5.1] def up # 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( title: 'Elasticsearch Pipeline Name', diff --git a/db/migrate/20171206000001_setting_default_locale2.rb b/db/migrate/20171206000001_setting_default_locale2.rb index 6892b6973..b0e850cfe 100644 --- a/db/migrate/20171206000001_setting_default_locale2.rb +++ b/db/migrate/20171206000001_setting_default_locale2.rb @@ -2,7 +2,7 @@ class SettingDefaultLocale2 < ActiveRecord::Migration[5.1] def up # 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') if setting diff --git a/db/migrate/20171207000001_permission_user_preferences_out_of_office.rb b/db/migrate/20171207000001_permission_user_preferences_out_of_office.rb index 75b81087a..d5a10268d 100644 --- a/db/migrate/20171207000001_permission_user_preferences_out_of_office.rb +++ b/db/migrate/20171207000001_permission_user_preferences_out_of_office.rb @@ -2,7 +2,7 @@ class PermissionUserPreferencesOutOfOffice < ActiveRecord::Migration[5.1] def up # 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( name: 'user_preferences.out_of_office', diff --git a/db/migrate/20171213000001_change_authorization_token_size.rb b/db/migrate/20171213000001_change_authorization_token_size.rb index 34a71e23f..8596792cb 100644 --- a/db/migrate/20171213000001_change_authorization_token_size.rb +++ b/db/migrate/20171213000001_change_authorization_token_size.rb @@ -1,7 +1,7 @@ class ChangeAuthorizationTokenSize < ActiveRecord::Migration[5.1] def up # 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 diff --git a/db/migrate/20180108000001_change_exchange_external_sync_identifier.rb b/db/migrate/20180108000001_change_exchange_external_sync_identifier.rb index 4c2de5e57..5bf4c65e6 100644 --- a/db/migrate/20180108000001_change_exchange_external_sync_identifier.rb +++ b/db/migrate/20180108000001_change_exchange_external_sync_identifier.rb @@ -1,7 +1,7 @@ class ChangeExchangeExternalSyncIdentifier < ActiveRecord::Migration[5.1] def up # 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( source: 'EWS::FolderContact' diff --git a/db/migrate/20180111000001_ldap_samaccountname_to_uid.rb b/db/migrate/20180111000001_ldap_samaccountname_to_uid.rb index 6a79d14b3..92d8dcc46 100644 --- a/db/migrate/20180111000001_ldap_samaccountname_to_uid.rb +++ b/db/migrate/20180111000001_ldap_samaccountname_to_uid.rb @@ -2,7 +2,7 @@ class LdapSamaccountnameToUid < ActiveRecord::Migration[5.1] def up # 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 end diff --git a/db/migrate/20180116000001_setting_ticket_number_ignore_system_id_support.rb b/db/migrate/20180116000001_setting_ticket_number_ignore_system_id_support.rb index 048f7192b..b76739e84 100644 --- a/db/migrate/20180116000001_setting_ticket_number_ignore_system_id_support.rb +++ b/db/migrate/20180116000001_setting_ticket_number_ignore_system_id_support.rb @@ -2,7 +2,7 @@ class SettingTicketNumberIgnoreSystemIdSupport < ActiveRecord::Migration[4.2] def up # 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( title: 'Ticket Number ignore system_id', diff --git a/db/migrate/20180128000001_chat_add_ip_country.rb b/db/migrate/20180128000001_chat_add_ip_country.rb index 7b70d32f5..980a360a6 100644 --- a/db/migrate/20180128000001_chat_add_ip_country.rb +++ b/db/migrate/20180128000001_chat_add_ip_country.rb @@ -2,7 +2,7 @@ class ChatAddIpCountry < ActiveRecord::Migration[5.1] def up # 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_country, :string, limit: 5000, null: true diff --git a/db/migrate/20180202000001_sidebar_customer_open_ticket_colored.rb b/db/migrate/20180202000001_sidebar_customer_open_ticket_colored.rb index 8f509451d..736c937db 100644 --- a/db/migrate/20180202000001_sidebar_customer_open_ticket_colored.rb +++ b/db/migrate/20180202000001_sidebar_customer_open_ticket_colored.rb @@ -2,7 +2,7 @@ class SidebarCustomerOpenTicketColored < ActiveRecord::Migration[5.1] def up # 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( title: 'Open ticket indicator', diff --git a/db/migrate/20180202000002_custom_ldap_login_attribute.rb b/db/migrate/20180202000002_custom_ldap_login_attribute.rb index 94017431e..4fdfcfbad 100644 --- a/db/migrate/20180202000002_custom_ldap_login_attribute.rb +++ b/db/migrate/20180202000002_custom_ldap_login_attribute.rb @@ -2,7 +2,7 @@ class CustomLdapLoginAttribute < ActiveRecord::Migration[5.1] def up # 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? perform_changes diff --git a/db/migrate/20180220000001_setting_attachment_preview.rb b/db/migrate/20180220000001_setting_attachment_preview.rb index c68580c44..6c8ed0973 100644 --- a/db/migrate/20180220000001_setting_attachment_preview.rb +++ b/db/migrate/20180220000001_setting_attachment_preview.rb @@ -2,7 +2,7 @@ class SettingAttachmentPreview < ActiveRecord::Migration[5.1] def up # 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( title: 'Sidebar Attachments', diff --git a/db/migrate/20180220000002_setting_user_organization_selector_with_email.rb b/db/migrate/20180220000002_setting_user_organization_selector_with_email.rb index c722ddce4..4513e89bd 100644 --- a/db/migrate/20180220000002_setting_user_organization_selector_with_email.rb +++ b/db/migrate/20180220000002_setting_user_organization_selector_with_email.rb @@ -2,7 +2,7 @@ class SettingUserOrganizationSelectorWithEmail < ActiveRecord::Migration[5.1] def up # 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( title: 'User Organization Selector - email', diff --git a/db/migrate/20180220171219_check_for_object_attributes.rb b/db/migrate/20180220171219_check_for_object_attributes.rb index 44767cd87..8de4127ad 100644 --- a/db/migrate/20180220171219_check_for_object_attributes.rb +++ b/db/migrate/20180220171219_check_for_object_attributes.rb @@ -1,6 +1,6 @@ class CheckForObjectAttributes < ActiveRecord::Migration[5.1] def change - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') attributes.each do |attribute| diff --git a/db/migrate/20180226085743_issue_1660_fix_tree_select_configurations.rb b/db/migrate/20180226085743_issue_1660_fix_tree_select_configurations.rb index 0b1d42e92..8efefaa3a 100644 --- a/db/migrate/20180226085743_issue_1660_fix_tree_select_configurations.rb +++ b/db/migrate/20180226085743_issue_1660_fix_tree_select_configurations.rb @@ -2,7 +2,7 @@ class Issue1660FixTreeSelectConfigurations < ActiveRecord::Migration[5.1] def change # 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? diff --git a/db/migrate/20180306084119_custom_html_email_css_font.rb b/db/migrate/20180306084119_custom_html_email_css_font.rb index 1d7b0e6f3..cd85fc8ee 100644 --- a/db/migrate/20180306084119_custom_html_email_css_font.rb +++ b/db/migrate/20180306084119_custom_html_email_css_font.rb @@ -2,7 +2,7 @@ class CustomHtmlEmailCssFont < ActiveRecord::Migration[5.1] def change # 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( title: 'HTML Email CSS Font', diff --git a/db/migrate/20180320000001_setting_table_group_by_show_count.rb b/db/migrate/20180320000001_setting_table_group_by_show_count.rb index a5a8641dc..357e57aad 100644 --- a/db/migrate/20180320000001_setting_table_group_by_show_count.rb +++ b/db/migrate/20180320000001_setting_table_group_by_show_count.rb @@ -2,7 +2,7 @@ class SettingTableGroupByShowCount < ActiveRecord::Migration[5.1] def up # 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( title: 'Open ticket indicator', diff --git a/db/migrate/20180327170847_issue_1905_exchange_login_from_remote_id.rb b/db/migrate/20180327170847_issue_1905_exchange_login_from_remote_id.rb index 2d78fb5cf..bc005bbfc 100644 --- a/db/migrate/20180327170847_issue_1905_exchange_login_from_remote_id.rb +++ b/db/migrate/20180327170847_issue_1905_exchange_login_from_remote_id.rb @@ -2,7 +2,7 @@ class Issue1905ExchangeLoginFromRemoteId < ActiveRecord::Migration[5.1] def change # 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 return if config.blank? diff --git a/db/migrate/20180418000001_setting_third_party_link_account_at_login.rb b/db/migrate/20180418000001_setting_third_party_link_account_at_login.rb index e563a4d64..64bd094f0 100644 --- a/db/migrate/20180418000001_setting_third_party_link_account_at_login.rb +++ b/db/migrate/20180418000001_setting_third_party_link_account_at_login.rb @@ -2,7 +2,7 @@ class SettingThirdPartyLinkAccountAtLogin < ActiveRecord::Migration[5.1] def up # 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( title: 'Automatic account link on initial logon', diff --git a/db/migrate/20180426134922_issue_1977_remove_invalid_user_foreign_keys.rb b/db/migrate/20180426134922_issue_1977_remove_invalid_user_foreign_keys.rb index ea38b65a5..ff0994f67 100644 --- a/db/migrate/20180426134922_issue_1977_remove_invalid_user_foreign_keys.rb +++ b/db/migrate/20180426134922_issue_1977_remove_invalid_user_foreign_keys.rb @@ -2,7 +2,7 @@ class Issue1977RemoveInvalidUserForeignKeys < ActiveRecord::Migration[5.1] def change # 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 OnlineNotification.joins('LEFT OUTER JOIN users ON online_notifications.user_id = users.id') diff --git a/db/migrate/20180502015927_issue_1219_zhtw_locale_typo.rb b/db/migrate/20180502015927_issue_1219_zhtw_locale_typo.rb index 04ca99524..953c3ccdf 100644 --- a/db/migrate/20180502015927_issue_1219_zhtw_locale_typo.rb +++ b/db/migrate/20180502015927_issue_1219_zhtw_locale_typo.rb @@ -3,7 +3,7 @@ class Issue1219ZhtwLocaleTypo < ActiveRecord::Migration[5.1] APPLICABLE_VERSION = Gem::Version.new('2.5.0') 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 if Locale.exists?(locale: 'zh-tw') @@ -20,7 +20,7 @@ class Issue1219ZhtwLocaleTypo < ActiveRecord::Migration[5.1] end 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 if Locale.exists?(locale: 'zj-tw') diff --git a/db/migrate/20180508182850_ticket_create_types_setting_issue_1987.rb b/db/migrate/20180508182850_ticket_create_types_setting_issue_1987.rb index fe2c9dec2..b7b6febb1 100644 --- a/db/migrate/20180508182850_ticket_create_types_setting_issue_1987.rb +++ b/db/migrate/20180508182850_ticket_create_types_setting_issue_1987.rb @@ -1,7 +1,7 @@ class TicketCreateTypesSettingIssue1987 < ActiveRecord::Migration[5.1] def up # 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( title: 'Default type for a new ticket', diff --git a/db/migrate/20180518000001_issue2029_sipgate_integration_enable.rb b/db/migrate/20180518000001_issue2029_sipgate_integration_enable.rb index d848c3542..ce10db4a8 100644 --- a/db/migrate/20180518000001_issue2029_sipgate_integration_enable.rb +++ b/db/migrate/20180518000001_issue2029_sipgate_integration_enable.rb @@ -2,7 +2,7 @@ class Issue2029SipgateIntegrationEnable < ActiveRecord::Migration[5.1] def change # 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? diff --git a/db/migrate/20180518100316_email_forward_prefix_setting_issue_1730.rb b/db/migrate/20180518100316_email_forward_prefix_setting_issue_1730.rb index 6be0478c6..e8f94ee12 100644 --- a/db/migrate/20180518100316_email_forward_prefix_setting_issue_1730.rb +++ b/db/migrate/20180518100316_email_forward_prefix_setting_issue_1730.rb @@ -1,7 +1,7 @@ class EmailForwardPrefixSettingIssue1730 < ActiveRecord::Migration[5.1] def up # 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( title: 'Ticket Subject Forward', diff --git a/db/migrate/20180521141004_ticket_last_contact_behavior.rb b/db/migrate/20180521141004_ticket_last_contact_behavior.rb index f9bf1c65e..a3a16683c 100644 --- a/db/migrate/20180521141004_ticket_last_contact_behavior.rb +++ b/db/migrate/20180521141004_ticket_last_contact_behavior.rb @@ -1,7 +1,7 @@ class TicketLastContactBehavior < ActiveRecord::Migration[5.1] def up # 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( title: 'Ticket Last Contact Behaviour', diff --git a/db/migrate/20180524182518_sms_support.rb b/db/migrate/20180524182518_sms_support.rb index 3857c3e94..61939f8a7 100644 --- a/db/migrate/20180524182518_sms_support.rb +++ b/db/migrate/20180524182518_sms_support.rb @@ -2,7 +2,7 @@ class SmsSupport < ActiveRecord::Migration[5.1] def up # 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( name: 'admin.channel_sms', diff --git a/db/migrate/20180529000001_issue_2035_recursive_ticket_trigger.rb b/db/migrate/20180529000001_issue_2035_recursive_ticket_trigger.rb index c215f8a11..3b8c230a6 100644 --- a/db/migrate/20180529000001_issue_2035_recursive_ticket_trigger.rb +++ b/db/migrate/20180529000001_issue_2035_recursive_ticket_trigger.rb @@ -2,7 +2,7 @@ class Issue2035RecursiveTicketTrigger < ActiveRecord::Migration[5.1] def change # 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( title: 'Recursive Ticket Triggers', diff --git a/db/migrate/20180604000001_setting_add_ticket_auto_assignment2.rb b/db/migrate/20180604000001_setting_add_ticket_auto_assignment2.rb index 90fa0472a..1f3a5500c 100644 --- a/db/migrate/20180604000001_setting_add_ticket_auto_assignment2.rb +++ b/db/migrate/20180604000001_setting_add_ticket_auto_assignment2.rb @@ -2,7 +2,7 @@ class SettingAddTicketAutoAssignment2 < ActiveRecord::Migration[5.1] def up # 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( title: 'Auto Assigment', diff --git a/db/migrate/20180611070839_add_ux_flow_next_up_to_macros.rb b/db/migrate/20180611070839_add_ux_flow_next_up_to_macros.rb index 655895966..df8b8fe6b 100644 --- a/db/migrate/20180611070839_add_ux_flow_next_up_to_macros.rb +++ b/db/migrate/20180611070839_add_ux_flow_next_up_to_macros.rb @@ -2,7 +2,7 @@ class AddUxFlowNextUpToMacros < ActiveRecord::Migration[5.1] def change # 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 :macros, :ux_flow_next_up, :string, default: 'none', null: false diff --git a/db/migrate/20180622140531_sequencer_log_level_setting.rb b/db/migrate/20180622140531_sequencer_log_level_setting.rb index ba3dbc3da..fbaab25f1 100644 --- a/db/migrate/20180622140531_sequencer_log_level_setting.rb +++ b/db/migrate/20180622140531_sequencer_log_level_setting.rb @@ -2,7 +2,7 @@ class SequencerLogLevelSetting < ActiveRecord::Migration[5.1] def change # 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( title: 'Sequencer log level', diff --git a/db/migrate/20180709020509_add_group_direction_to_overviews.rb b/db/migrate/20180709020509_add_group_direction_to_overviews.rb index fba072601..1cc2cacbf 100644 --- a/db/migrate/20180709020509_add_group_direction_to_overviews.rb +++ b/db/migrate/20180709020509_add_group_direction_to_overviews.rb @@ -1,7 +1,7 @@ class AddGroupDirectionToOverviews < ActiveRecord::Migration[5.1] def change # 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 :overviews, :group_direction, :string, limit: 250, null: true end diff --git a/db/migrate/20180716060129_issue_2019_fix_double_domain_links_in_trigger_emails.rb b/db/migrate/20180716060129_issue_2019_fix_double_domain_links_in_trigger_emails.rb index 6514a0579..430651d59 100644 --- a/db/migrate/20180716060129_issue_2019_fix_double_domain_links_in_trigger_emails.rb +++ b/db/migrate/20180716060129_issue_2019_fix_double_domain_links_in_trigger_emails.rb @@ -2,7 +2,7 @@ class Issue2019FixDoubleDomainLinksInTriggerEmails < ActiveRecord::Migration[5.1 DOUBLE_DOMAIN_REGEX = %r{(?<=)}.freeze def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') Trigger.where('perform LIKE ?', '%notification.email: %') .find_each do |t| diff --git a/db/migrate/20180806000001_fixed_twitter_ticket_article_preferences7.rb b/db/migrate/20180806000001_fixed_twitter_ticket_article_preferences7.rb index 5f39b5796..71dad8644 100644 --- a/db/migrate/20180806000001_fixed_twitter_ticket_article_preferences7.rb +++ b/db/migrate/20180806000001_fixed_twitter_ticket_article_preferences7.rb @@ -2,7 +2,7 @@ class FixedTwitterTicketArticlePreferences7 < ActiveRecord::Migration[5.0] def up # return if it's a new setup - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') # find article preferences with Twitter::NullObject and replace it with nill to prevent elasticsearch index issue article_type_ids = Ticket::Article::Type.where(name: ['twitter status', 'twitter direct-message']).pluck(:id) diff --git a/db/migrate/20180809000001_cti_generic_api.rb b/db/migrate/20180809000001_cti_generic_api.rb index 0bb55aabe..3a92417f7 100644 --- a/db/migrate/20180809000001_cti_generic_api.rb +++ b/db/migrate/20180809000001_cti_generic_api.rb @@ -2,7 +2,7 @@ class CtiGenericApi < ActiveRecord::Migration[5.1] def up # 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( title: 'cti integration', diff --git a/db/migrate/20180830000001_setting_delivery_temporary_failed.rb b/db/migrate/20180830000001_setting_delivery_temporary_failed.rb index a9bc1dc05..900538dc5 100644 --- a/db/migrate/20180830000001_setting_delivery_temporary_failed.rb +++ b/db/migrate/20180830000001_setting_delivery_temporary_failed.rb @@ -2,7 +2,7 @@ class SettingDeliveryTemporaryFailed < ActiveRecord::Migration[5.1] def up # 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( title: 'Defines postmaster filter.', diff --git a/db/migrate/20180911064647_issue_2140_reset_ldap_config.rb b/db/migrate/20180911064647_issue_2140_reset_ldap_config.rb index dbc3643ae..b12b06f4e 100644 --- a/db/migrate/20180911064647_issue_2140_reset_ldap_config.rb +++ b/db/migrate/20180911064647_issue_2140_reset_ldap_config.rb @@ -4,7 +4,7 @@ class Issue2140ResetLdapConfig < ActiveRecord::Migration[5.1] def up # return if it's a new setup - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') ldap_config = Setting.get('ldap_config') diff --git a/db/migrate/20180913000001_setting_add_system_bcc.rb b/db/migrate/20180913000001_setting_add_system_bcc.rb index 11e39ed8c..7d6b8264d 100644 --- a/db/migrate/20180913000001_setting_add_system_bcc.rb +++ b/db/migrate/20180913000001_setting_add_system_bcc.rb @@ -2,7 +2,7 @@ class SettingAddSystemBcc < ActiveRecord::Migration[5.1] def up # 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( title: 'Bcc address for all outgoing emails', diff --git a/db/migrate/20180913000002_permission_add_time_accounting.rb b/db/migrate/20180913000002_permission_add_time_accounting.rb index 79d609480..98661a0e3 100644 --- a/db/migrate/20180913000002_permission_add_time_accounting.rb +++ b/db/migrate/20180913000002_permission_add_time_accounting.rb @@ -2,7 +2,7 @@ class PermissionAddTimeAccounting < ActiveRecord::Migration[5.1] def up # 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( name: 'admin.time_accounting', diff --git a/db/migrate/20180919000000_setting_update_pretty_date_format.rb b/db/migrate/20180919000000_setting_update_pretty_date_format.rb index 85b80c4d6..4b8159102 100644 --- a/db/migrate/20180919000000_setting_update_pretty_date_format.rb +++ b/db/migrate/20180919000000_setting_update_pretty_date_format.rb @@ -2,7 +2,7 @@ class SettingUpdatePrettyDateFormat < ActiveRecord::Migration[5.1] def up # 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: 'pretty_date_format') return if !setting diff --git a/db/migrate/20181010000000_setting_add_sipgate_alternative_fqdn.rb b/db/migrate/20181010000000_setting_add_sipgate_alternative_fqdn.rb index 6e3a7da35..17716a5cb 100644 --- a/db/migrate/20181010000000_setting_add_sipgate_alternative_fqdn.rb +++ b/db/migrate/20181010000000_setting_add_sipgate_alternative_fqdn.rb @@ -2,7 +2,7 @@ class SettingAddSipgateAlternativeFqdn < ActiveRecord::Migration[5.1] def up # 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( title: 'sipgate.io alternative fqdn', diff --git a/db/migrate/20181017000001_cti_generic_api2.rb b/db/migrate/20181017000001_cti_generic_api2.rb index 9cd9975b7..036783537 100644 --- a/db/migrate/20181017000001_cti_generic_api2.rb +++ b/db/migrate/20181017000001_cti_generic_api2.rb @@ -2,7 +2,7 @@ class CtiGenericApi2 < ActiveRecord::Migration[5.1] def up # 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 !column_exists?(:cti_logs, :initialized_at) return if column_exists?(:cti_logs, :initialized_at_cleanup) diff --git a/db/migrate/20181023163804_add_stats_backends.rb b/db/migrate/20181023163804_add_stats_backends.rb index b46c2da17..4086e9d7d 100644 --- a/db/migrate/20181023163804_add_stats_backends.rb +++ b/db/migrate/20181023163804_add_stats_backends.rb @@ -2,7 +2,7 @@ class AddStatsBackends < ActiveRecord::Migration[5.1] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') # add the dashboard stats backend for 'Stats::TicketWaitingTime' Setting.create_if_not_exists( diff --git a/db/migrate/20181030000001_setting_add_placetel1.rb b/db/migrate/20181030000001_setting_add_placetel1.rb index d2b25d04a..592538028 100644 --- a/db/migrate/20181030000001_setting_add_placetel1.rb +++ b/db/migrate/20181030000001_setting_add_placetel1.rb @@ -2,7 +2,7 @@ class SettingAddPlacetel1 < ActiveRecord::Migration[5.1] def change # 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( title: 'Placetel integration', diff --git a/db/migrate/20181108123847_add_country_attribute_to_users.rb b/db/migrate/20181108123847_add_country_attribute_to_users.rb index 479304391..fb9991932 100644 --- a/db/migrate/20181108123847_add_country_attribute_to_users.rb +++ b/db/migrate/20181108123847_add_country_attribute_to_users.rb @@ -4,7 +4,7 @@ class AddCountryAttributeToUsers < ActiveRecord::Migration[5.1] def up # 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 the country attribute already exists current_country_attribute = ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country') diff --git a/db/migrate/20181120150357_issue_2345_es_attachment_max_size_in_mb_setting_lower_default.rb b/db/migrate/20181120150357_issue_2345_es_attachment_max_size_in_mb_setting_lower_default.rb index dd7e4e91c..6df5d336f 100644 --- a/db/migrate/20181120150357_issue_2345_es_attachment_max_size_in_mb_setting_lower_default.rb +++ b/db/migrate/20181120150357_issue_2345_es_attachment_max_size_in_mb_setting_lower_default.rb @@ -2,7 +2,7 @@ class Issue2345EsAttachmentMaxSizeInMbSettingLowerDefault < ActiveRecord::Migrat def change # 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') # don't change non default/custom value return if Setting.get('es_attachment_max_size_in_mb') != 50 diff --git a/db/migrate/20181123000000_issue_2368_add_indices_to_histories_and_tickets.rb b/db/migrate/20181123000000_issue_2368_add_indices_to_histories_and_tickets.rb index 8d319f92e..79cb29ca7 100644 --- a/db/migrate/20181123000000_issue_2368_add_indices_to_histories_and_tickets.rb +++ b/db/migrate/20181123000000_issue_2368_add_indices_to_histories_and_tickets.rb @@ -1,6 +1,6 @@ class Issue2368AddIndicesToHistoriesAndTickets < ActiveRecord::Migration[5.1] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') add_index :histories, :related_o_id if !index_exists?(:histories, :related_o_id) add_index :histories, :related_history_object_id if !index_exists?(:histories, :related_history_object_id) diff --git a/db/migrate/20181203000000_setting_add_email_full_quote_header.rb b/db/migrate/20181203000000_setting_add_email_full_quote_header.rb index bb32d63d2..2cef647f6 100644 --- a/db/migrate/20181203000000_setting_add_email_full_quote_header.rb +++ b/db/migrate/20181203000000_setting_add_email_full_quote_header.rb @@ -1,7 +1,7 @@ class SettingAddEmailFullQuoteHeader < ActiveRecord::Migration[5.1] def up # 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( title: 'Email - quote header', diff --git a/db/migrate/20190131000001_setting_change_ticket_zoom_attachment_preview.rb b/db/migrate/20190131000001_setting_change_ticket_zoom_attachment_preview.rb index 296db7b3f..478a6ae96 100644 --- a/db/migrate/20190131000001_setting_change_ticket_zoom_attachment_preview.rb +++ b/db/migrate/20190131000001_setting_change_ticket_zoom_attachment_preview.rb @@ -1,7 +1,7 @@ class SettingChangeTicketZoomAttachmentPreview < ActiveRecord::Migration[5.1] def up # 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( title: 'Sidebar Attachments', diff --git a/db/migrate/20190208000001_setting_timezone_default.rb b/db/migrate/20190208000001_setting_timezone_default.rb index 564563e48..463b52fc4 100644 --- a/db/migrate/20190208000001_setting_timezone_default.rb +++ b/db/migrate/20190208000001_setting_timezone_default.rb @@ -1,7 +1,7 @@ class SettingTimezoneDefault < ActiveRecord::Migration[5.1] def up # 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( title: 'Timezone', diff --git a/db/migrate/20190314084909_object_manager_attribute_date_remove_future_past.rb b/db/migrate/20190314084909_object_manager_attribute_date_remove_future_past.rb index 8e3a4e07a..a44590fd7 100644 --- a/db/migrate/20190314084909_object_manager_attribute_date_remove_future_past.rb +++ b/db/migrate/20190314084909_object_manager_attribute_date_remove_future_past.rb @@ -2,7 +2,7 @@ class ObjectManagerAttributeDateRemoveFuturePast < ActiveRecord::Migration[5.1] def change # 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.where(data_type: 'date').each do |attribute| attribute.data_option = attribute.data_option.except(:future, :past) diff --git a/db/migrate/20190328000000_rename_locale_on_users.rb b/db/migrate/20190328000000_rename_locale_on_users.rb index af3e3e7cb..74deaeb08 100644 --- a/db/migrate/20190328000000_rename_locale_on_users.rb +++ b/db/migrate/20190328000000_rename_locale_on_users.rb @@ -1,6 +1,6 @@ class RenameLocaleOnUsers < ActiveRecord::Migration[5.1] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') return if ActiveRecord::Base.connection.columns('users').map(&:name).exclude?('locale') ActiveRecord::Migration.rename_column(:users, :locale, :_locale) diff --git a/db/migrate/20190405000001_database_indexes.rb b/db/migrate/20190405000001_database_indexes.rb index ed212a3ed..3c77f421d 100644 --- a/db/migrate/20190405000001_database_indexes.rb +++ b/db/migrate/20190405000001_database_indexes.rb @@ -2,7 +2,7 @@ class DatabaseIndexes < ActiveRecord::Migration[5.1] def change # return if it's a new setup - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') map = { activity_streams: [ diff --git a/db/migrate/20190408000001_issue_2541_fix_notification_email_without_body.rb b/db/migrate/20190408000001_issue_2541_fix_notification_email_without_body.rb index 1cd2edc41..642d2aae9 100644 --- a/db/migrate/20190408000001_issue_2541_fix_notification_email_without_body.rb +++ b/db/migrate/20190408000001_issue_2541_fix_notification_email_without_body.rb @@ -2,7 +2,7 @@ class Issue2541FixNotificationEmailWithoutBody < ActiveRecord::Migration[5.1] def up # return if it's a new setup - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') # there might be Job/Trigger selectors referencing the current user # that get e.g. validated in callbacks diff --git a/db/migrate/20190415000001_setting_es_multi_index.rb b/db/migrate/20190415000001_setting_es_multi_index.rb index 9ae3c2554..7bb6a2807 100644 --- a/db/migrate/20190415000001_setting_es_multi_index.rb +++ b/db/migrate/20190415000001_setting_es_multi_index.rb @@ -2,7 +2,7 @@ class SettingEsMultiIndex < ActiveRecord::Migration[5.1] def up # 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( title: 'Elasticsearch Multi Index', diff --git a/db/migrate/20190418000000_normalize_setting_ticket_number_ignore_system_id.rb b/db/migrate/20190418000000_normalize_setting_ticket_number_ignore_system_id.rb index 85c805422..912ea1ba6 100644 --- a/db/migrate/20190418000000_normalize_setting_ticket_number_ignore_system_id.rb +++ b/db/migrate/20190418000000_normalize_setting_ticket_number_ignore_system_id.rb @@ -1,6 +1,6 @@ class NormalizeSettingTicketNumberIgnoreSystemId < ActiveRecord::Migration[5.1] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') return if !Setting.exists?(name: 'ticket_number_ignore_system_id') Setting.find_by(name: 'ticket_number_ignore_system_id') diff --git a/db/migrate/20190531180304_initialize_knowledge_base.rb b/db/migrate/20190531180304_initialize_knowledge_base.rb index d0b6bd26d..e4bacc129 100644 --- a/db/migrate/20190531180304_initialize_knowledge_base.rb +++ b/db/migrate/20190531180304_initialize_knowledge_base.rb @@ -142,7 +142,7 @@ class InitializeKnowledgeBase < ActiveRecord::Migration[5.0] frontend: true ) - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') Permission.create_if_not_exists( name: 'admin.knowledge_base', diff --git a/db/migrate/20190626000001_setting_update_karma_level.rb b/db/migrate/20190626000001_setting_update_karma_level.rb index c27987262..8a0fc9228 100644 --- a/db/migrate/20190626000001_setting_update_karma_level.rb +++ b/db/migrate/20190626000001_setting_update_karma_level.rb @@ -2,7 +2,7 @@ class SettingUpdateKarmaLevel < ActiveRecord::Migration[5.1] def up # 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( 'karma_levels', diff --git a/db/migrate/20190715141227_saml_auth.rb b/db/migrate/20190715141227_saml_auth.rb index 6314a46a1..acca2fd19 100644 --- a/db/migrate/20190715141227_saml_auth.rb +++ b/db/migrate/20190715141227_saml_auth.rb @@ -1,7 +1,7 @@ class SamlAuth < ActiveRecord::Migration[5.2] def up # 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( title: 'Authentication via %s', diff --git a/db/migrate/20190717210244_issue_2641_kb_color_change_limit.rb b/db/migrate/20190717210244_issue_2641_kb_color_change_limit.rb index 76fbf9c3f..4ea4233b3 100644 --- a/db/migrate/20190717210244_issue_2641_kb_color_change_limit.rb +++ b/db/migrate/20190717210244_issue_2641_kb_color_change_limit.rb @@ -1,6 +1,6 @@ class Issue2641KbColorChangeLimit < ActiveRecord::Migration[5.2] def change - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') change_column :knowledge_bases, :color_highlight, :string, limit: 25 change_column :knowledge_bases, :color_header, :string, limit: 25 diff --git a/db/migrate/20190718140450_forget_insecure_sessions.rb b/db/migrate/20190718140450_forget_insecure_sessions.rb index 14540120f..ffe55f159 100644 --- a/db/migrate/20190718140450_forget_insecure_sessions.rb +++ b/db/migrate/20190718140450_forget_insecure_sessions.rb @@ -4,7 +4,7 @@ # because those are incompatible with secure cookies anyway. class ForgetInsecureSessions < ActiveRecord::Migration[5.2] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') return if Setting.get('http_type') != 'https' ActiveRecord::SessionStore::Session.destroy_all diff --git a/db/migrate/20190724000001_rename_reserved_words.rb b/db/migrate/20190724000001_rename_reserved_words.rb index 865097eaa..d62a6d0dd 100644 --- a/db/migrate/20190724000001_rename_reserved_words.rb +++ b/db/migrate/20190724000001_rename_reserved_words.rb @@ -1,6 +1,6 @@ class RenameReservedWords < ActiveRecord::Migration[5.1] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') models = ObjectManager.list_objects.map(&:underscore).map { |object| object.tr('_', '/') }.map(&:classify).map(&:constantize) diff --git a/db/migrate/20190806000001_setting_postmaster_send_reject_email.rb b/db/migrate/20190806000001_setting_postmaster_send_reject_email.rb index 6c1ea1975..e76f63c1d 100644 --- a/db/migrate/20190806000001_setting_postmaster_send_reject_email.rb +++ b/db/migrate/20190806000001_setting_postmaster_send_reject_email.rb @@ -2,7 +2,7 @@ class SettingPostmasterSendRejectEmail < ActiveRecord::Migration[5.2] def up # 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( title: 'Send postmaster mail if mail too large', diff --git a/db/migrate/20190814000001_object_manager_attribute_ticket_article_body_maxlength_change.rb b/db/migrate/20190814000001_object_manager_attribute_ticket_article_body_maxlength_change.rb index bf22ba4bf..a9253b57c 100644 --- a/db/migrate/20190814000001_object_manager_attribute_ticket_article_body_maxlength_change.rb +++ b/db/migrate/20190814000001_object_manager_attribute_ticket_article_body_maxlength_change.rb @@ -1,6 +1,6 @@ class ObjectManagerAttributeTicketArticleBodyMaxlengthChange < ActiveRecord::Migration[5.1] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') attribute = ObjectManager::Attribute.get( object: 'TicketArticle', diff --git a/db/migrate/20190903165443_issue_2595_gitlab_placeholder.rb b/db/migrate/20190903165443_issue_2595_gitlab_placeholder.rb index c7e3467db..fbba634a2 100644 --- a/db/migrate/20190903165443_issue_2595_gitlab_placeholder.rb +++ b/db/migrate/20190903165443_issue_2595_gitlab_placeholder.rb @@ -1,7 +1,7 @@ class Issue2595GitlabPlaceholder < ActiveRecord::Migration[5.2] def change # 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: 'auth_gitlab_credentials') setting.options['form'].last['placeholder'] = 'https://gitlab.YOURDOMAIN.com/api/v4/' diff --git a/db/migrate/20190918114553_issue_2867_footer_header_public_link.rb b/db/migrate/20190918114553_issue_2867_footer_header_public_link.rb index 78749ed4c..c800bfc3f 100644 --- a/db/migrate/20190918114553_issue_2867_footer_header_public_link.rb +++ b/db/migrate/20190918114553_issue_2867_footer_header_public_link.rb @@ -1,7 +1,7 @@ class Issue2867FooterHeaderPublicLink < ActiveRecord::Migration[5.2] def up # 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 :knowledge_base_menu_items, :location, :string, null: false, default: 'header' add_index :knowledge_base_menu_items, :location diff --git a/db/migrate/20191001090809_create_active_job_locks.rb b/db/migrate/20191001090809_create_active_job_locks.rb index a099d243e..9dd0f12bb 100644 --- a/db/migrate/20191001090809_create_active_job_locks.rb +++ b/db/migrate/20191001090809_create_active_job_locks.rb @@ -1,7 +1,7 @@ class CreateActiveJobLocks < ActiveRecord::Migration[5.2] def change # 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 :active_job_locks do |t| t.string :lock_key diff --git a/db/migrate/20191029101733_issue_2608_missing_trigger_permission.rb b/db/migrate/20191029101733_issue_2608_missing_trigger_permission.rb index d29aeb663..048736f2a 100644 --- a/db/migrate/20191029101733_issue_2608_missing_trigger_permission.rb +++ b/db/migrate/20191029101733_issue_2608_missing_trigger_permission.rb @@ -1,6 +1,6 @@ class Issue2608MissingTriggerPermission < ActiveRecord::Migration[5.2] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') Permission.create_if_not_exists( name: 'admin.trigger', diff --git a/db/migrate/20191107050249_issue_2460_fix_corrupted_twitter_ids.rb b/db/migrate/20191107050249_issue_2460_fix_corrupted_twitter_ids.rb index 7ee6fc536..36dc9263c 100644 --- a/db/migrate/20191107050249_issue_2460_fix_corrupted_twitter_ids.rb +++ b/db/migrate/20191107050249_issue_2460_fix_corrupted_twitter_ids.rb @@ -1,6 +1,6 @@ class Issue2460FixCorruptedTwitterIds < ActiveRecord::Migration[5.2] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') Channel.where(area: 'Twitter::Account').each do |channel| diff --git a/db/migrate/20191107181428_issue_2715_fix_broken_twitter_urls.rb b/db/migrate/20191107181428_issue_2715_fix_broken_twitter_urls.rb index 124b5b199..d1db7a818 100644 --- a/db/migrate/20191107181428_issue_2715_fix_broken_twitter_urls.rb +++ b/db/migrate/20191107181428_issue_2715_fix_broken_twitter_urls.rb @@ -2,7 +2,7 @@ require_dependency 'issue_2715_fix_broken_twitter_urls_job' # Rails autoloading class Issue2715FixBrokenTwitterUrls < ActiveRecord::Migration[5.2] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') Issue2715FixBrokenTwitterUrlsJob.perform_later end diff --git a/db/migrate/20191129102720_active_job_lock_cleanup_job_scheduler.rb b/db/migrate/20191129102720_active_job_lock_cleanup_job_scheduler.rb index 2f4f58722..830ef6884 100644 --- a/db/migrate/20191129102720_active_job_lock_cleanup_job_scheduler.rb +++ b/db/migrate/20191129102720_active_job_lock_cleanup_job_scheduler.rb @@ -1,6 +1,6 @@ class ActiveJobLockCleanupJobScheduler < ActiveRecord::Migration[5.2] def up - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') Scheduler.create_or_update( name: 'Cleanup ActiveJob locks.', diff --git a/db/migrate/20200121000001_smime_support.rb b/db/migrate/20200121000001_smime_support.rb index a2a427b57..c7c385565 100644 --- a/db/migrate/20200121000001_smime_support.rb +++ b/db/migrate/20200121000001_smime_support.rb @@ -2,7 +2,7 @@ class SMIMESupport < ActiveRecord::Migration[5.2] def up # 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( title: 'S/MIME integration', diff --git a/db/migrate/20200205000001_chat_add_allow_website.rb b/db/migrate/20200205000001_chat_add_allow_website.rb index d75a15ba8..77e496bc2 100644 --- a/db/migrate/20200205000001_chat_add_allow_website.rb +++ b/db/migrate/20200205000001_chat_add_allow_website.rb @@ -2,7 +2,7 @@ class ChatAddAllowWebsite < ActiveRecord::Migration[5.1] def up # 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, :whitelisted_websites, :string, limit: 5000, null: true end diff --git a/db/migrate/20200401000001_service_now_config.rb b/db/migrate/20200401000001_service_now_config.rb index 4a120dbde..a9687de54 100644 --- a/db/migrate/20200401000001_service_now_config.rb +++ b/db/migrate/20200401000001_service_now_config.rb @@ -2,7 +2,7 @@ class ServiceNowConfig < ActiveRecord::Migration[4.2] def up # 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( title: 'Defines postmaster filter.', diff --git a/db/migrate/20200419204445_setting_websocket_backend.rb b/db/migrate/20200419204445_setting_websocket_backend.rb index 665ff66bf..903c8feec 100644 --- a/db/migrate/20200419204445_setting_websocket_backend.rb +++ b/db/migrate/20200419204445_setting_websocket_backend.rb @@ -1,7 +1,7 @@ class SettingWebsocketBackend < ActiveRecord::Migration[5.2] def change # 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( title: 'Websocket backend', diff --git a/db/migrate/20200507095900_imap_authentication_migration_cleanup_job_scheduler.rb b/db/migrate/20200507095900_imap_authentication_migration_cleanup_job_scheduler.rb index 01c234ea4..2660df7e0 100644 --- a/db/migrate/20200507095900_imap_authentication_migration_cleanup_job_scheduler.rb +++ b/db/migrate/20200507095900_imap_authentication_migration_cleanup_job_scheduler.rb @@ -2,7 +2,7 @@ class ImapAuthenticationMigrationCleanupJobScheduler < ActiveRecord::Migration[5 def change # 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_or_update( name: 'Delete obsolete classic IMAP backup.', diff --git a/db/migrate/20200709091905_maintenance_checkmk_wordings_on_settings.rb b/db/migrate/20200709091905_maintenance_checkmk_wordings_on_settings.rb index c2f5155ee..f423664ab 100644 --- a/db/migrate/20200709091905_maintenance_checkmk_wordings_on_settings.rb +++ b/db/migrate/20200709091905_maintenance_checkmk_wordings_on_settings.rb @@ -2,7 +2,7 @@ class MaintenanceCheckmkWordingsOnSettings < ActiveRecord::Migration[5.2] def change # 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.find_by(name: 'check_mk_integration').update!( title: 'Checkmk integration', diff --git a/db/migrate/20200709094556_issue_3110_service_now_provider.rb b/db/migrate/20200709094556_issue_3110_service_now_provider.rb index cf52b3066..0ad0c53de 100644 --- a/db/migrate/20200709094556_issue_3110_service_now_provider.rb +++ b/db/migrate/20200709094556_issue_3110_service_now_provider.rb @@ -2,7 +2,7 @@ class Issue3110ServiceNowProvider < ActiveRecord::Migration[5.2] def change # return if it's a new setup - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') ExternalSync.where(source: 'ServiceNow').find_each do |row| article = Ticket.find(row.o_id).articles.first diff --git a/db/migrate/20200716124141_issue_3123_external_sync_ticket_merge.rb b/db/migrate/20200716124141_issue_3123_external_sync_ticket_merge.rb index 53c631228..7d762188b 100644 --- a/db/migrate/20200716124141_issue_3123_external_sync_ticket_merge.rb +++ b/db/migrate/20200716124141_issue_3123_external_sync_ticket_merge.rb @@ -2,7 +2,7 @@ class Issue3123ExternalSyncTicketMerge < ActiveRecord::Migration[5.2] def change # return if it's a new setup - return if !Setting.find_by(name: 'system_init_done') + return if !Setting.exists?(name: 'system_init_done') merged_ticket_ids_with_external_sync.each do |id_from| id_to = merged_ticket_ids_map[id_from] diff --git a/lib/app_version.rb b/lib/app_version.rb index 3bc0a647f..3db20ed7c 100644 --- a/lib/app_version.rb +++ b/lib/app_version.rb @@ -34,7 +34,7 @@ send also reload type to clients =end def self.set(reload_required = false, type = 'app_version') - return false if !Setting.find_by(name: 'app_version') + return false if !Setting.exists?(name: 'app_version') version = "#{Time.zone.now.strftime('%Y%m%d%H%M%S')}:#{reload_required}" Setting.set('app_version', version) diff --git a/lib/facebook.rb b/lib/facebook.rb index 7ac187d1f..a2cbe505d 100644 --- a/lib/facebook.rb +++ b/lib/facebook.rb @@ -271,7 +271,7 @@ result end articles.each do |article| - next if Ticket::Article.find_by(message_id: article[:message_id]) + next if Ticket::Article.exists?(message_id: article[:message_id]) # set ticket state to open if not new ticket_state = get_state(page, post, ticket) diff --git a/lib/import/otrs/history.rb b/lib/import/otrs/history.rb index a95712925..8c7d10d2c 100644 --- a/lib/import/otrs/history.rb +++ b/lib/import/otrs/history.rb @@ -41,7 +41,7 @@ module Import # we perform further import # otherwise the following import logic (add) will # try to add the history attribute, too - sleep 1 until ::History::Attribute.find_by(name: name) + sleep 1 until ::History::Attribute.exists?(name: name) true end end diff --git a/lib/telegram.rb b/lib/telegram.rb index 4221ab045..c256870db 100644 --- a/lib/telegram.rb +++ b/lib/telegram.rb @@ -705,7 +705,7 @@ returns # prevent multiple update if !params[:edited_message] - return if Ticket::Article.find_by(message_id: Telegram.message_id(params)) + return if Ticket::Article.exists?(message_id: Telegram.message_id(params)) end # update article diff --git a/lib/twitter_sync.rb b/lib/twitter_sync.rb index f3d0885c7..e99bccc43 100644 --- a/lib/twitter_sync.rb +++ b/lib/twitter_sync.rb @@ -693,7 +693,7 @@ process webhook messages from twitter @payload['direct_message_events'].each do |item| next if item['type'] != 'message_create' - next if Ticket::Article.find_by(message_id: item['id']) + next if Ticket::Article.exists?(message_id: item['id']) user = to_user_webhook(item['message_create']['sender_id']) ticket = to_ticket(item, user, channel.options[:sync][:direct_messages][:group_id], channel) @@ -703,7 +703,7 @@ process webhook messages from twitter if @payload['tweet_create_events'].present? @payload['tweet_create_events'].each do |item| - next if Ticket::Article.find_by(message_id: item['id']) + next if Ticket::Article.exists?(message_id: item['id']) # check if it's mention group_id = nil diff --git a/spec/lib/import/otrs/history_examples.rb b/spec/lib/import/otrs/history_examples.rb index 1f988d559..23e4ed4af 100644 --- a/spec/lib/import/otrs/history_examples.rb +++ b/spec/lib/import/otrs/history_examples.rb @@ -13,7 +13,7 @@ end RSpec.shared_examples 'Import::OTRS::History' do it 'responds to init_callback' do expect(::History).to receive(:add) - allow(::History::Attribute).to receive(:find_by).and_return(true) + allow(::History::Attribute).to receive(:exists?).and_return(true) blank_instance = described_class.new({}) expect(blank_instance).to respond_to('init_callback') end diff --git a/spec/support/system_init_done.rb b/spec/support/system_init_done.rb index a2cf844ac..2b0da5192 100644 --- a/spec/support/system_init_done.rb +++ b/spec/support/system_init_done.rb @@ -1,12 +1,12 @@ module SystemInitDoneHelper def system_init_done(state = true) - # generally allow all calls to Setting.find_by to avoid + # generally allow all calls to Setting.exists? to avoid # RSpec errors where a different Setting is accessed - allow(Setting).to receive(:find_by).and_call_original + allow(Setting).to receive(:exists?).and_call_original # just mock the Setting check for `system_init_done` # and return the given parameter value - expect(Setting).to receive(:find_by).with(name: 'system_init_done').and_return(state) + expect(Setting).to receive(:exists?).with(name: 'system_init_done').and_return(state) end end