Commit 4a57ad96 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '273160_refactor_require_migration_helper' into 'master'

Extend require_migration helper on EE

See merge request gitlab-org/gitlab!47509
parents 0be88112 a29f7e91
# frozen_string_literal: true
module EE
module RequireMigration
extend ActiveSupport::Concern
MIGRATION_FOLDERS = %w[ee/db/geo/migrate ee/db/geo/post_migrate].freeze
class_methods do
def migration_folders
@migration_folders ||= super + MIGRATION_FOLDERS
end
end
end
end
...@@ -14,8 +14,7 @@ class RequireMigration ...@@ -14,8 +14,7 @@ class RequireMigration
end end
end end
FOSS_MIGRATION_FOLDERS = %w[db/migrate db/post_migrate].freeze MIGRATION_FOLDERS = %w[db/migrate db/post_migrate].freeze
ALL_MIGRATION_FOLDERS = (FOSS_MIGRATION_FOLDERS + %w[ee/db/geo/migrate ee/db/geo/post_migrate]).freeze
SPEC_FILE_PATTERN = /.+\/(?<file_name>.+)_spec\.rb/.freeze SPEC_FILE_PATTERN = /.+\/(?<file_name>.+)_spec\.rb/.freeze
class << self class << self
...@@ -37,11 +36,13 @@ class RequireMigration ...@@ -37,11 +36,13 @@ class RequireMigration
private private
def migration_folders def migration_folders
Gitlab.ee? ? ALL_MIGRATION_FOLDERS : FOSS_MIGRATION_FOLDERS MIGRATION_FOLDERS
end end
end end
end end
RequireMigration.prepend_if_ee('EE::RequireMigration')
def require_migration!(file_name = nil) def require_migration!(file_name = nil)
location_info = caller_locations.first.path.match(RequireMigration::SPEC_FILE_PATTERN) location_info = caller_locations.first.path.match(RequireMigration::SPEC_FILE_PATTERN)
file_name ||= location_info[:file_name] file_name ||= location_info[:file_name]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment