From 9fb3b8a45605e66ae6463d8e9ae63168b80d3ae2 Mon Sep 17 00:00:00 2001 From: thespad Date: Thu, 3 Dec 2026 09:59:34 +0000 Subject: [PATCH] Add helper for major version DB migrations --- README.md | 7 +++++++ readme-vars.yml | 13 ++++++++++--- root/migrate | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 root/migrate diff --git a/README.md b/README.md index 147ee3e..c15d334 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,12 @@ We support all of the official [environment variables](https://docs.joinmastodon For more information check out the [mastodon documentation](https://docs.joinmastodon.org/). +### Upgrade from 4.7 to 5.0 + +* Stop your running 4.7 container and pull the new image, make sure the DB and Redis are still running +* Run `docker compose run --rm -e SKIP_POST_DEPLOYMENT_MIGRATIONS=true --entrypoint /bin/bash mastodon migrate` +* Once the migrations are complete, start the Mastodon container as normal + ### Running separate sidekiq instances It is currently only supported to run a single queue per container instance *or* all queues in a single container instance. @@ -435,6 +441,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **03.12.26:** - Add migration helper for major version upgrades. * **29.11.26:** - Fetch Ruby from library image to match the version required by upstream. * **05.07.26:** - Rebase to Alpine 3.24. * **21.10.25:** - Add prometheus exporter support. diff --git a/readme-vars.yml b/readme-vars.yml index d916f0f..bdd15a1 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -78,11 +78,11 @@ app_setup_block_enabled: true app_setup_block: | We provide aliases for the common commands that execute in the correct context so that environment variables from secrets are available to them: - * To generate keys for `SECRET_KEY_BASE` & `OTP_SECRET` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:latest generate-secret` once for each. + * To generate keys for `SECRET_KEY_BASE` & `OTP_SECRET` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:{{ release_tag }} generate-secret` once for each. - * To generate keys for `VAPID_PRIVATE_KEY` & `VAPID_PUBLIC_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:latest generate-vapid` + * To generate keys for `VAPID_PRIVATE_KEY` & `VAPID_PUBLIC_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:{{ release_tag }} generate-vapid` - * To generate keys for `ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY`, `ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT`, & `ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:latest generate-active-record` + * To generate keys for `ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY`, `ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT`, & `ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:{{ release_tag }} generate-active-record` Both of the secret generation aliases above can be run without any other setup having been carried out. @@ -96,6 +96,12 @@ app_setup_block: | For more information check out the [mastodon documentation](https://docs.joinmastodon.org/). + ### Upgrade from 4.7 to 5.0 + + * Stop your running 4.7 container and pull the new image, make sure the DB and Redis are still running + * Run `docker compose run --rm -e SKIP_POST_DEPLOYMENT_MIGRATIONS=true --entrypoint /bin/bash mastodon migrate` + * Once the migrations are complete, start the Mastodon container as normal + ### Running separate sidekiq instances It is currently only supported to run a single queue per container instance *or* all queues in a single container instance. @@ -173,6 +179,7 @@ init_diagram: | "mastodon:latest" <- Base Images # changelog changelogs: + - {date: "03.12.26:", desc: "Add migration helper for major version upgrades."} - {date: "29.11.26:", desc: "Fetch Ruby from library image to match the version required by upstream."} - {date: "05.07.26:", desc: "Rebase to Alpine 3.24."} - {date: "21.10.25:", desc: "Add prometheus exporter support."} diff --git a/root/migrate b/root/migrate new file mode 100755 index 0000000..385b35d --- /dev/null +++ b/root/migrate @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +cd /app/www || exit 1 + +bundle exec rails db:migrate