summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-08 15:18:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-08 15:18:11 +0000
commitdcc56fe601580b5d8f6c3da32550c6523f2baff3 (patch)
treef68c28bf7c8715de7242464b344620ae5c394036 /db/migrate
parent571b02efc9442e73538c3438eb593a83d7807779 (diff)
downloadgitlab-ce-dcc56fe601580b5d8f6c3da32550c6523f2baff3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20230504084524_remove_gitlab_import_source.rb32
-rw-r--r--db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb8
2 files changed, 40 insertions, 0 deletions
diff --git a/db/migrate/20230504084524_remove_gitlab_import_source.rb b/db/migrate/20230504084524_remove_gitlab_import_source.rb
new file mode 100644
index 00000000000..287b1cd3139
--- /dev/null
+++ b/db/migrate/20230504084524_remove_gitlab_import_source.rb
@@ -0,0 +1,32 @@
+# 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
diff --git a/db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb b/db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb
new file mode 100644
index 00000000000..aacb26643b9
--- /dev/null
+++ b/db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddAnthropicApiKeyApplicationSetting < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :encrypted_anthropic_api_key, :binary
+ add_column :application_settings, :encrypted_anthropic_api_key_iv, :binary
+ end
+end