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
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-30 21:53:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-30 21:53:49 +0300
commit52c415c0aa74b27fb203e4c9c8d95d2c1566e870 (patch)
tree7576623c94d4668b635f1375a9beac29f0f2c12f /lib
parenta0111b1203b94b47e9d68be934b3a6f2ba01eed0 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/gitlab/db/migration_fix_15_11.rake30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/db/migration_fix_15_11.rake b/lib/tasks/gitlab/db/migration_fix_15_11.rake
new file mode 100644
index 00000000000..fbfee856abb
--- /dev/null
+++ b/lib/tasks/gitlab/db/migration_fix_15_11.rake
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+desc 'db | migration_fix_15_11'
+task migration_fix_15_11: [:environment] do
+ next if Gitlab.com?
+
+ only_on = %i[main ci].select { |db| Gitlab::Database.has_database?(db) }
+ Gitlab::Database::EachDatabase.each_database_connection(only: only_on) do |conn, database|
+ begin
+ first_migration = conn.execute('SELECT * FROM schema_migrations ORDER BY version ASC LIMIT 1')
+ rescue ActiveRecord::StatementInvalid
+ # Uninitialized DB, skip
+ next
+ end
+ next if first_migration.none? # No migrations have been run yet
+ # If we are affected, the first migration in the schema_migrations table
+ # will be 20220314184009
+ next unless first_migration.first['version'] == '20220314184009'
+
+ puts "Running 15.11 migration fix for #{database}"
+ fixes = File.readlines(Rails.root.join('db/15_11_migration_fixes.txt')).map(&:chomp)
+ conn.transaction do
+ fixes.each do |version|
+ conn.execute("INSERT INTO schema_migrations (version) VALUES ('#{version}')")
+ end
+ end
+ end
+end
+
+Rake::Task['db:migrate'].enhance(['migration_fix_15_11'])