Skip to content

Commit 8e616f4

Browse files
marbindrakonclaude
andcommitted
feat: add SKIP_MIGRATIONS env var to docker entrypoint
Allows skipping the automatic migrate call at startup by setting SKIP_MIGRATIONS=true. Useful when manually faking migrations before starting the app, e.g. when rolling back to v0.9 after pruning the migrations ledger. Default behavior (run migrations) is unchanged. Updates upgrading.md to document the recovery procedure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8ed8123 commit 8e616f4

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

docker-entrypoint.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ if [ -n "${SAM_PLUGIN_DIR}" ] || [ -n "${SAM_PLUGIN_PACKAGES}" ]; then
4444
python manage.py collectstatic --noinput
4545
fi
4646

47-
# Run database migrations
48-
echo "Running database migrations..."
49-
python manage.py migrate --noinput
47+
# Run database migrations (set SKIP_MIGRATIONS=true to disable, e.g. when
48+
# manually faking migrations before starting the app after a rollback)
49+
if [ "${SKIP_MIGRATIONS}" = "true" ]; then
50+
echo "Skipping database migrations (SKIP_MIGRATIONS=true)"
51+
else
52+
echo "Running database migrations..."
53+
python manage.py migrate --noinput
54+
fi
5055

5156
# Create superuser if credentials provided and user doesn't exist
5257
# Django's createsuperuser --noinput reads DJANGO_SUPERUSER_USERNAME,

docs/upgrading.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ python manage.py migrate health --prune
9999
`--prune` removes rows that no longer correspond to a migration file on disk.
100100
It operates on one app at a time, so both apps must be run separately.
101101

102+
> **Note:** Running `--prune` blocks rollback to v0.9. Without the old
103+
> migration records in `django_migrations`, a v0.9 image will treat migrations
104+
> `0002` and later as unapplied and attempt to run them against an
105+
> already-migrated schema, causing startup failures. Only prune if you are
106+
> confident you will not need to roll back. If you do need to roll back after
107+
> pruning, start the v0.9 container with `SKIP_MIGRATIONS=true`, exec in, run
108+
> `python manage.py migrate --fake`, then restart without the flag.
109+
102110
---
103111

104112
### Plugin authors

0 commit comments

Comments
 (0)