Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb25
-rw-r--r--db/schema_migrations/202305151536001
-rw-r--r--doc/update/index.md6
-rw-r--r--doc/user/project/settings/import_export.md1
-rw-r--r--spec/migrations/20230515153600_finalize_back_fill_prepared_at_merge_requests_spec.rb76
5 files changed, 109 insertions, 0 deletions
diff --git a/db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb b/db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb
new file mode 100644
index 00000000000..6c0e4e722d2
--- /dev/null
+++ b/db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class FinalizeBackFillPreparedAtMergeRequests < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ MIGRATION = 'BackfillPreparedAtMergeRequests'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: MIGRATION,
+ table_name: :merge_requests,
+ column_name: :id,
+ job_arguments: []
+ )
+ end
+
+ def down
+ # noop
+ end
+end
diff --git a/db/schema_migrations/20230515153600 b/db/schema_migrations/20230515153600
new file mode 100644
index 00000000000..59cf7492b56
--- /dev/null
+++ b/db/schema_migrations/20230515153600
@@ -0,0 +1 @@
+147c720a8103a14bd96f01618b68f5e46ed44b2b72cca43d17d7abfe0632c980 \ No newline at end of file
diff --git a/doc/update/index.md b/doc/update/index.md
index 5409dcb71f5..93d3edd2ef5 100644
--- a/doc/update/index.md
+++ b/doc/update/index.md
@@ -273,6 +273,12 @@ and [Helm Chart deployments](https://docs.gitlab.com/charts/). They come with ap
[migrate `user_type` values from `NULL` to `0`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/115849). This
migration may take multiple days to complete on larger GitLab instances. Make sure the migration
has completed successfully before upgrading to 16.1.0.
+- A `BackfillPreparedAtMergeRequests` background migration will be finalized with
+ the `FinalizeBackFillPreparedAtMergeRequests` post-deploy migration.
+ GitLab 15.10.0 introduced a [batched background migration](background_migrations.md#batched-background-migrations) to
+ [backfill `prepared_at` values on the `merge_requests` table](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/111865). This
+ migration may take multiple days to complete on larger GitLab instances. Make sure the migration
+ has completed successfully before upgrading to 16.1.0.
### 16.0.0
diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md
index 958246908bc..8730db7af58 100644
--- a/doc/user/project/settings/import_export.md
+++ b/doc/user/project/settings/import_export.md
@@ -181,6 +181,7 @@ Items that are **not** exported include:
- Secure files
- [Activity logs for Git-related events](https://gitlab.com/gitlab-org/gitlab/-/issues/214700) (for example, pushing and creating tags)
- Security policies associated with your project
+- Links between issues and linked items
Migrating projects with file exports uses the same export and import mechanisms as creating projects from templates at the [group](../../group/custom_project_templates.md) and
[instance](../../admin_area/custom_project_templates.md) levels. Therefore, the list of exported items is the same.
diff --git a/spec/migrations/20230515153600_finalize_back_fill_prepared_at_merge_requests_spec.rb b/spec/migrations/20230515153600_finalize_back_fill_prepared_at_merge_requests_spec.rb
new file mode 100644
index 00000000000..71487280af0
--- /dev/null
+++ b/spec/migrations/20230515153600_finalize_back_fill_prepared_at_merge_requests_spec.rb
@@ -0,0 +1,76 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe FinalizeBackFillPreparedAtMergeRequests, :migration, feature_category: :code_review_workflow do
+ let(:batched_migrations) { table(:batched_background_migrations) }
+
+ let!(:migration) { described_class::MIGRATION }
+
+ describe '#up' do
+ shared_examples 'finalizes the migration' do
+ it 'finalizes the migration' do
+ allow_next_instance_of(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner) do |runner|
+ expect(runner).to receive(:finalize).with(migration, :merge_requests, :id, [nil, "up"])
+ end
+ end
+ end
+
+ context 'when prepared at backfilling migration is missing' do
+ before do
+ batched_migrations.where(job_class_name: migration).delete_all
+ end
+
+ it 'warns migration not found' do
+ expect(Gitlab::AppLogger)
+ .to receive(:warn).with(/Could not find batched background migration for the given configuration:/)
+
+ migrate!
+ end
+ end
+
+ context 'with backfilling migration present' do
+ let!(:project_namespace_backfill) do
+ batched_migrations.create!(
+ job_class_name: migration,
+ table_name: :merge_requests,
+ column_name: :id,
+ job_arguments: [],
+ interval: 2.minutes,
+ min_value: 1,
+ max_value: 2,
+ batch_size: 1000,
+ sub_batch_size: 200,
+ gitlab_schema: :gitlab_main,
+ status: 3 # finished
+ )
+ end
+
+ context 'when prepared at backfilling migration finished successfully' do
+ it 'does not raise exception' do
+ expect { migrate! }.not_to raise_error
+ end
+ end
+
+ context 'when prepared at backfilling migration is paused' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:status, :description) do
+ 0 | 'paused'
+ 1 | 'active'
+ 4 | 'failed'
+ 5 | 'finalizing'
+ end
+
+ with_them do
+ before do
+ project_namespace_backfill.update!(status: status)
+ end
+
+ it_behaves_like 'finalizes the migration'
+ end
+ end
+ end
+ end
+end