Skip to content

Commit

Permalink
Fix pre-refresh hook
Browse files Browse the repository at this point in the history
  • Loading branch information
dhelonious committed Sep 19, 2024
1 parent f1857c9 commit 358709e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Go to *Preferences/Administration/Server settings/Branding* and add your *Contac

## Requests fail after upgrade

If some requests fail after upgrading to a newer version, and there are log entries showing errors about missing columns and tables, the database has not been migrated properly. Use `mastodon-server.db-migrate` to start the migration manually. Use `mastodon-server.db-rollback` to rollback a database migration, which may be necessary when downgrading.
If some requests fail after upgrading to a newer version, and there are log entries showing errors about missing columns and tables, the database has not been migrated properly. Use `mastodon-server.db-migrate` to start the migrations manually. Use `mastodon-server.db-rollback` to rollback the database migrations, which may be necessary when downgrading.

See the [Mastodon troubleshooting page](https://docs.joinmastodon.org/admin/troubleshooting/#after-an-upgrade-to-a-newer-version-some-requests-fail-and-the-logs-show-error-messages-about-missing-columns-or-tables-why) for more information.

Expand Down
2 changes: 1 addition & 1 deletion snap/hooks/post-refresh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if [ "$SNAP_VERSION" != "$CURRENT_SNAP_VERSION" ]; then
link_mastodon_config
upgrade_mastodon_config

migration_required
migrations_required
fi
fi

Expand Down
3 changes: 2 additions & 1 deletion snap/hooks/pre-refresh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

. "$SNAP/snap.env"
. "$SNAP/postgres.env"
. "$SNAP/mastodon.env"

export CURRENT_PG_VERSION="$(get_postgres_version_file)"

Expand All @@ -14,4 +15,4 @@ if [ "$PG_VERSION" != "$CURRENT_PG_VERSION" ]; then
pg_dumpall.wrapper -f "$SNAP_COMMON/database.sql"
fi

pre_migration_required
pre_migrations_required
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ parts:
- YARN_VERSION: "4.5.0" # NOTE: https://github.com/yarnpkg/berry/releases/latest
- RUBY_BRANCH: "3.3" # NOTE: must be updated with ruby source
- BUNDLER_VERSION: "2.5.18" # NOTE: see `Gemfile.lock`
- BIRD_UI_TAG: "2.0.0rc49" # NOTE: https://github.com/ronilaukkarinen/mastodon-bird-ui/releases/latest
- BIRD_UI_TAG: "2.0.0rc51" # NOTE: https://github.com/ronilaukkarinen/mastodon-bird-ui/releases/latest
- TANGERINE_UI_TAG: "2.0.0-pre6" # NOTE: https://github.com/nileane/TangerineUI-for-Mastodon/releases/latest
- RAILS_ENV: production
- NODE_ENV: production
Expand Down
10 changes: 6 additions & 4 deletions src/mastodon/bin/migrate_if_required
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

. "$SNAP/mastodon.env"

if [ "$(snapctl get migration-required)" == true ]; then
if [ "$(snapctl get migrations-required)" == true ]; then
echo Start db migrations
mastodon_db_migrate
elif [ "$(snapctl get pre-migration-required)" == true ]; then
elif [ "$(snapctl get pre-migrations-required)" == true ]; then
echo Start pre-deployment db migrations
SKIP_POST_DEPLOYMENT_MIGRATIONS=true mastodon_db_migrate
fi

reset_migration_required
reset_pre_migration_required
reset_migrations_required
reset_pre_migrations_required
16 changes: 8 additions & 8 deletions src/mastodon/mastodon.env
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,20 @@ reset_recompile_required() {
snapctl set recompile-required=false
}

migration_required() {
snapctl set migration-required=true
migrations_required() {
snapctl set migrations-required=true
}

reset_migration_required() {
snapctl set migration-required=false
reset_migrations_required() {
snapctl set migrations-required=false
}

pre_migration_required() {
snapctl set pre-migration-required=true
pre_migrations_required() {
snapctl set pre-migrations-required=true
}

reset_pre_migration_required() {
snapctl set pre-migration-required=false
reset_pre_migrations_required() {
snapctl set pre-migrations-required=false
}

get_status_max_chars_file() {
Expand Down

0 comments on commit 358709e

Please sign in to comment.