summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-01 13:38:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-01 13:38:24 +0000
commit0396082c12f518f48e136968dbf0b4e5f774641c (patch)
tree9ee22b3f2d65483c316d30397b7e065d4dec5fec /db
parentcb7e80d1211dae947e40290a834cbe29ee36364e (diff)
downloadgitlab-ce-0396082c12f518f48e136968dbf0b4e5f774641c.tar.gz
Add latest changes from gitlab-org/gitlab@15-2-stable-ee
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb6
-rw-r--r--db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb21
2 files changed, 22 insertions, 5 deletions
diff --git a/db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb b/db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb
index 68769f9e4e3..f3c57692a0d 100644
--- a/db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb
+++ b/db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb
@@ -10,7 +10,7 @@ class CreateVulnerabilityReadsForAnExistingVulnerabilityRecord < Gitlab::Databas
def up
execute(<<~SQL)
- CREATE FUNCTION #{FUNCTION_NAME}() RETURNS trigger
+ CREATE OR REPLACE FUNCTION #{FUNCTION_NAME}() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
@@ -39,6 +39,10 @@ class CreateVulnerabilityReadsForAnExistingVulnerabilityRecord < Gitlab::Databas
SQL
execute(<<~SQL)
+ DROP TRIGGER IF EXISTS #{TRIGGER_NAME} ON vulnerabilities;
+ SQL
+
+ execute(<<~SQL)
CREATE TRIGGER #{TRIGGER_NAME}
AFTER UPDATE ON vulnerabilities
FOR EACH ROW
diff --git a/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb b/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb
index b5124ce667c..912578d6b7c 100644
--- a/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb
+++ b/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb
@@ -14,10 +14,6 @@ class RescheduleBackfillImportedIssueSearchData < Gitlab::Database::Migration[2.
delete_batched_background_migration(MIGRATION, :issues, :id, [])
# reschedule the migration
- min_value = Gitlab::Database::BackgroundMigration::BatchedMigration.find_by(
- job_class_name: "BackfillIssueSearchData"
- )&.max_value || BATCH_MIN_VALUE
-
queue_batched_background_migration(
MIGRATION,
:issues,
@@ -32,4 +28,21 @@ class RescheduleBackfillImportedIssueSearchData < Gitlab::Database::Migration[2.
def down
delete_batched_background_migration(MIGRATION, :issues, :id, [])
end
+
+ private
+
+ def min_value
+ start_value = Gitlab::Database::BackgroundMigration::BatchedMigration.find_by(
+ job_class_name: "BackfillIssueSearchData"
+ )&.max_value
+
+ return BATCH_MIN_VALUE unless start_value
+
+ max_value = Issue.maximum(:id)
+
+ return BATCH_MIN_VALUE unless max_value
+
+ # Just in case the issue's max ID is now lower than the history in the table
+ [start_value, max_value].min
+ end
end