Remove migrations with bad ids

We could rename them later but we don't want them to be executed under
their new name. So we need to deploy the version rename in the database
first.
This commit is contained in:
Maikel Linke
2024-01-15 14:30:01 +11:00
parent 301add4992
commit dc411eb42b
15 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
# frozen_string_literal: true
class RenameOffendingMigrations < ActiveRecord::Migration[7.0]
MIGRATION_IDS = {
'20231002000136871': "20231002000136",
'20231002000136872': "20231002000137",
'20231002000136876': "20231002000138",
'20231002000136877': "20231002000139",
'20231002000136879': "20231002000140",
'20231002000136926': "20231002000141",
'20231002000136952': "20231002000142",
'20231002000136955': "20231002000143",
'20231002000136959': "20231002000144",
'20231002000136976': "20231002000145",
'20231002000137115': "20231002000146",
'20231002000137116': "20231002000147",
'20231003000823494': "20231003000823",
}.freeze
def up
MIGRATION_IDS.each do |bad_id, good_id|
execute <<~SQL.squish
UPDATE schema_migrations
SET version='#{good_id}'
WHERE version='#{bad_id}'
SQL
end
end
def down
MIGRATION_IDS.each do |bad_id, good_id|
execute <<~SQL.squish
UPDATE schema_migrations
SET version='#{bad_id}'
WHERE version='#{good_id}'
SQL
end
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 20231003000823494) do
ActiveRecord::Schema[7.0].define(version: 2024_01_15_022359) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "plpgsql"