diff options
Diffstat (limited to 'db')
6 files changed, 50 insertions, 5 deletions
diff --git a/db/migrate/20221209110934_update_import_sources_on_application_settings.rb b/db/migrate/20221209110934_update_import_sources_on_application_settings.rb index ff15b06412f..59955d30544 100644 --- a/db/migrate/20221209110934_update_import_sources_on_application_settings.rb +++ b/db/migrate/20221209110934_update_import_sources_on_application_settings.rb @@ -9,11 +9,10 @@ class UpdateImportSourcesOnApplicationSettings < Gitlab::Database::Migration[2.0 end def up - # rubocop: disable Style/GuardClause - unless import_sources.empty? - ApplicationSetting.update_all(import_sources: import_sources.reject { |x| x == "google_code" }) - end - # rubocop: enable Style/GuardClause + return if import_sources.empty? + + new_sources = import_sources - ['google_code'] + ApplicationSetting.update_all(import_sources: new_sources.to_yaml) end def down diff --git a/db/migrate/20221209110935_fix_update_import_sources_on_application_settings.rb b/db/migrate/20221209110935_fix_update_import_sources_on_application_settings.rb new file mode 100644 index 00000000000..d3123113e82 --- /dev/null +++ b/db/migrate/20221209110935_fix_update_import_sources_on_application_settings.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# This fixes 20221209110934_update_import_sources_on_application_settings.rb, which +# previously serialized a YAML column into a string. +class FixUpdateImportSourcesOnApplicationSettings < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + class ApplicationSetting < MigrationRecord + end + + def up + sources = ApplicationSetting.last&.import_sources + + return unless sources.is_a?(String) + return if sources.start_with?('---') + + sources = YAML.safe_load(sources) + + ApplicationSetting.update_all(import_sources: sources.to_yaml) + end + + def down; end +end diff --git a/db/post_migrate/20221212103743_add_index_id_partition_id_to_ci_build.rb b/db/post_migrate/20221212103743_add_index_id_partition_id_to_ci_build.rb new file mode 100644 index 00000000000..aab67272a77 --- /dev/null +++ b/db/post_migrate/20221212103743_add_index_id_partition_id_to_ci_build.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexIdPartitionIdToCiBuild < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE_NAME = :ci_builds + INDEX_NAME = :index_ci_builds_on_id_partition_id_unique + COLUMNS = %i[id partition_id].freeze + + def up + add_concurrent_index(TABLE_NAME, COLUMNS, unique: true, name: INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/schema_migrations/20221209110935 b/db/schema_migrations/20221209110935 new file mode 100644 index 00000000000..6e39531220d --- /dev/null +++ b/db/schema_migrations/20221209110935 @@ -0,0 +1 @@ +6a25429104daf2b735f0a22e48dc631ded1aebe7d6f5f9d61520af184f6b5075
\ No newline at end of file diff --git a/db/schema_migrations/20221212103743 b/db/schema_migrations/20221212103743 new file mode 100644 index 00000000000..7f225c9516f --- /dev/null +++ b/db/schema_migrations/20221212103743 @@ -0,0 +1 @@ +a961cf4e53556fe7899fbabc7bc686d5edaf061abe5a008eb7a6304f64f2f22f
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index cae57e8aae2..754d9796403 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -28657,6 +28657,8 @@ CREATE INDEX index_ci_builds_on_commit_id_and_type_and_ref ON ci_builds USING bt CREATE INDEX index_ci_builds_on_commit_id_artifacts_expired_at_and_id ON ci_builds USING btree (commit_id, artifacts_expire_at, id) WHERE (((type)::text = 'Ci::Build'::text) AND ((retried = false) OR (retried IS NULL)) AND ((name)::text = ANY (ARRAY[('sast'::character varying)::text, ('secret_detection'::character varying)::text, ('dependency_scanning'::character varying)::text, ('container_scanning'::character varying)::text, ('dast'::character varying)::text]))); +CREATE UNIQUE INDEX index_ci_builds_on_id_partition_id_unique ON ci_builds USING btree (id, partition_id); + CREATE INDEX index_ci_builds_on_project_id_and_id ON ci_builds USING btree (project_id, id); CREATE INDEX index_ci_builds_on_project_id_and_name_and_ref ON ci_builds USING btree (project_id, name, ref) WHERE (((type)::text = 'Ci::Build'::text) AND ((status)::text = 'success'::text) AND ((retried = false) OR (retried IS NULL))); |