debian-mirror-gitlab/db/migrate/20230504084524_remove_gitlab_import_source.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
919 B
Ruby
Raw Normal View History

2023-07-09 08:55:56 +05:30
# frozen_string_literal: true
class RemoveGitlabImportSource < Gitlab::Database::Migration[2.1]
include Gitlab::Utils::StrongMemoize
disable_ddl_transaction!
restrict_gitlab_migration gitlab_schema: :gitlab_main
class ApplicationSetting < MigrationRecord
end
def up
return if import_sources.empty?
new_sources = import_sources - ['gitlab']
ApplicationSetting.update_all(import_sources: new_sources.to_yaml)
end
def down
## a reversion is not needed as the Gitlab.com importer is no longer
# a supported import source. Attempting to save it as one will result
# in an ActiveRecord error.
end
def import_sources
## the last ApplicationSetting record is used to determine application settings
import_sources = ApplicationSetting.last&.import_sources
import_sources.nil? ? [] : YAML.safe_load(import_sources)
end
strong_memoize_attr(:import_sources)
end