Fixes #3702 - One of DB migrations timestamp breaks migrations queue
This commit is contained in:
parent
64f1b0c75b
commit
2573723269
3 changed files with 42 additions and 0 deletions
35
.rubocop/cop/zammad/correct_migration_timestamp.rb
Normal file
35
.rubocop/cop/zammad/correct_migration_timestamp.rb
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
module RuboCop
|
||||||
|
module Cop
|
||||||
|
module Zammad
|
||||||
|
# This cop checks if migration file name begins with a valid timestamp
|
||||||
|
# https://github.com/zammad/zammad/issues/3702
|
||||||
|
class CorrectMigrationTimestamp < Base
|
||||||
|
MSG = 'Migration filename must begin with a valid timestamp'.freeze
|
||||||
|
|
||||||
|
def on_new_investigation
|
||||||
|
file_path = processed_source.file_path
|
||||||
|
|
||||||
|
return if !migration?(file_path)
|
||||||
|
return if config.file_to_exclude?(file_path) || config.allowed_camel_case_file?(file_path)
|
||||||
|
return if filename_good?(file_path)
|
||||||
|
|
||||||
|
add_global_offense(MSG)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def migration?(file_path)
|
||||||
|
match_path? %r{(?<!spec/)db/(migrate|addon/[^/]+)/.+\.rb}, file_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def filename_good?(file_path)
|
||||||
|
File
|
||||||
|
.basename(file_path)
|
||||||
|
.match? %r{^20\d{12}_}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,6 +3,7 @@
|
||||||
require_relative 'cop/zammad/exists_condition'
|
require_relative 'cop/zammad/exists_condition'
|
||||||
require_relative 'cop/zammad/exists_date_time_precision'
|
require_relative 'cop/zammad/exists_date_time_precision'
|
||||||
require_relative 'cop/zammad/exists_reset_column_information'
|
require_relative 'cop/zammad/exists_reset_column_information'
|
||||||
|
require_relative 'cop/zammad/correct_migration_timestamp'
|
||||||
require_relative 'cop/zammad/have_no_over_not_to'
|
require_relative 'cop/zammad/have_no_over_not_to'
|
||||||
require_relative 'cop/zammad/no_to_sym_on_string'
|
require_relative 'cop/zammad/no_to_sym_on_string'
|
||||||
require_relative 'cop/zammad/prefer_negated_if_over_unless'
|
require_relative 'cop/zammad/prefer_negated_if_over_unless'
|
||||||
|
|
|
@ -6,6 +6,12 @@ class SettingAddInternalArticleCheck < ActiveRecord::Migration[5.2]
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
return if !Setting.exists?(name: 'system_init_done')
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
|
# this migration used to have a wrong timestmap
|
||||||
|
# remove old timestmap from schema_migrations table
|
||||||
|
# when re-running with the fixed timestamp
|
||||||
|
# https://github.com/zammad/zammad/issues/3702
|
||||||
|
return if ActiveRecord::SchemaMigration.where(version: '202104070000001').destroy_all.present?
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Define postmaster filter.',
|
title: 'Define postmaster filter.',
|
||||||
name: '5500_postmaster_internal_article_check',
|
name: '5500_postmaster_internal_article_check',
|
Loading…
Reference in a new issue