mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 18:45:41 +01:00
Add explicit migration breakpoints (#33089)
This commit is contained in:
parent
86b45a4a48
commit
1ee149d015
2 changed files with 14 additions and 2 deletions
6
.github/workflows/test-migrations.yml
vendored
6
.github/workflows/test-migrations.yml
vendored
|
@ -12,6 +12,7 @@ on:
|
||||||
- '**/*.rb'
|
- '**/*.rb'
|
||||||
- '.github/workflows/test-migrations.yml'
|
- '.github/workflows/test-migrations.yml'
|
||||||
- 'lib/tasks/tests.rake'
|
- 'lib/tasks/tests.rake'
|
||||||
|
- 'lib/tasks/db.rake'
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
|
@ -90,6 +91,11 @@ jobs:
|
||||||
bin/rails db:drop
|
bin/rails db:drop
|
||||||
bin/rails db:create
|
bin/rails db:create
|
||||||
SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails tests:migrations:prepare_database
|
SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails tests:migrations:prepare_database
|
||||||
|
|
||||||
|
# Migrate up to v4.2.0 breakpoint
|
||||||
|
bin/rails db:migrate VERSION=20230907150100
|
||||||
|
|
||||||
|
# Migrate the rest
|
||||||
SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails db:migrate
|
SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails db:migrate
|
||||||
bin/rails db:migrate
|
bin/rails db:migrate
|
||||||
bin/rails tests:migrations:check_database
|
bin/rails tests:migrations:check_database
|
||||||
|
|
|
@ -43,8 +43,14 @@ namespace :db do
|
||||||
end
|
end
|
||||||
|
|
||||||
task pre_migration_check: :environment do
|
task pre_migration_check: :environment do
|
||||||
version = ActiveRecord::Base.connection.database_version
|
pg_version = ActiveRecord::Base.connection.database_version
|
||||||
abort 'This version of Mastodon requires PostgreSQL 12.0 or newer. Please update PostgreSQL before updating Mastodon.' if version < 120_000
|
abort 'This version of Mastodon requires PostgreSQL 12.0 or newer. Please update PostgreSQL before updating Mastodon.' if pg_version < 120_000
|
||||||
|
|
||||||
|
schema_version = ActiveRecord::Migrator.current_version
|
||||||
|
abort <<~MESSAGE if ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] && schema_version < 2023_09_07_150100
|
||||||
|
Zero-downtime migrations from Mastodon versions earlier than 4.2.0 are not supported.
|
||||||
|
Please update to Mastodon 4.2.x first or upgrade by stopping all services and running migrations without `SKIP_POST_DEPLOYMENT_MIGRATIONS`.
|
||||||
|
MESSAGE
|
||||||
end
|
end
|
||||||
|
|
||||||
Rake::Task['db:migrate'].enhance(['db:pre_migration_check'])
|
Rake::Task['db:migrate'].enhance(['db:pre_migration_check'])
|
||||||
|
|
Loading…
Reference in a new issue