diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-11 15:09:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-11 15:09:03 +0300 |
commit | b9ab87c14ce9ebe8284aeffa32c1cee934156e58 (patch) | |
tree | 85c5a1c4febe868ad0090ab6795f6fe548714541 /db | |
parent | fb7b6bceee41fc6e5dba72a24519dec8f2713075 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
5 files changed, 57 insertions, 0 deletions
diff --git a/db/post_migrate/20220420214703_schedule_backfill_draft_status_on_merge_requests_corrected_regex.rb b/db/post_migrate/20220420214703_schedule_backfill_draft_status_on_merge_requests_corrected_regex.rb new file mode 100644 index 00000000000..1001aca583b --- /dev/null +++ b/db/post_migrate/20220420214703_schedule_backfill_draft_status_on_merge_requests_corrected_regex.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class ScheduleBackfillDraftStatusOnMergeRequestsCorrectedRegex < Gitlab::Database::Migration[1.0] + INDEX_NAME = "tmp_index_merge_requests_draft_and_status" + MIGRATION = "BackfillDraftStatusOnMergeRequestsWithCorrectedRegex" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 50 + CORRECTED_REGEXP_STR = "^(\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP)" + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_requests, :id, + where: "draft = false AND state_id = 1 AND ((title)::text ~* '#{CORRECTED_REGEXP_STR}'::text)", + name: INDEX_NAME + + eligible_mrs = MergeRequest.where(state_id: 1) + .where(draft: false) + .where("title ~* ?", "#{CORRECTED_REGEXP_STR}") + + queue_background_migration_jobs_by_range_at_intervals( + eligible_mrs, + MIGRATION, + DELAY_INTERVAL, + track_jobs: true, + batch_size: BATCH_SIZE + ) + end + + def down + remove_concurrent_index_by_name :merge_requests, INDEX_NAME + end +end diff --git a/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb b/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb new file mode 100644 index 00000000000..860756de298 --- /dev/null +++ b/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class BackfillDeploymentsFinishedAt < Gitlab::Database::Migration[2.0] + DEPLOYMENT_STATUS_SUCCESS = 2 # Equivalent to Deployment.statuses[:success] + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + BATCH_SIZE = 100 + + def up + define_batchable_model('deployments') + .where(finished_at: nil) + .where(status: DEPLOYMENT_STATUS_SUCCESS) + .each_batch(of: BATCH_SIZE) { |relation| relation.update_all('finished_at = created_at') } + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20220420214703 b/db/schema_migrations/20220420214703 new file mode 100644 index 00000000000..ff519126cc2 --- /dev/null +++ b/db/schema_migrations/20220420214703 @@ -0,0 +1 @@ +fdf562fd8681b104ef91842e036b1153e7a4786529bcd2e35fcb964ecd25345e
\ No newline at end of file diff --git a/db/schema_migrations/20220426185933 b/db/schema_migrations/20220426185933 new file mode 100644 index 00000000000..46a67db3499 --- /dev/null +++ b/db/schema_migrations/20220426185933 @@ -0,0 +1 @@ +56001affed339a7184ee20c7e34707aa33ba405db4f83d8926228b1bf72d5af8
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index d9d721a6b69..e4a24a866d4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -29753,6 +29753,8 @@ CREATE INDEX tmp_index_issues_on_issue_type_and_id ON issues USING btree (issue_ CREATE INDEX tmp_index_members_on_state ON members USING btree (state) WHERE (state = 2); +CREATE INDEX tmp_index_merge_requests_draft_and_status ON merge_requests USING btree (id) WHERE ((draft = false) AND (state_id = 1) AND ((title)::text ~* '^(\[draft\]|\(draft\)|draft:|draft|\[WIP\]|WIP:|WIP)'::text)); + CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_child_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NOT NULL) AND (traversal_ids = '{}'::integer[])); CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_root_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NULL) AND (traversal_ids = '{}'::integer[])); |