Skip to content

Commit cb57361

Browse files
committed
Validate committed Django migrations
1 parent c24dbad commit cb57361

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.bu-isciii-deployment/state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"deployment_health/views.py": "d19cc3e8fef8519bae2b7fbdc25d17f6ae7df02479aa8890f4b4d250bb07f2e4",
6969
"docker-compose.prod.yml": "30df3b5bf90a4d88a81a2d577c34a5f7066c4ee02e2ffccdea4ef7c488a19619",
7070
"docker-compose.test.yml": "86f2ec8a4da1a1d537de58265b0dad9fd73c50173f05659c7171cd9db91de434",
71-
"install.sh": "c6b8f8c2994034a0524eeff3e735ca294acd27af839e3cb5565bf415a4107c70",
71+
"install.sh": "31d1aae9853b50e85e797f9903130d642e2f8ed502a58d04b972aad3799b5558",
7272
"nextstrain/Dockerfile": "f1a3426c2ac065ddb0841e21d657f068c9584e47b8193077cd3bd85e15391335",
7373
"nextstrain/auspice-config.json": "6fc666bf5a0d05293dfdb6cc6b0800637e52c3335bda065b78c036fb6af0d7af",
7474
"scripts/container_start.sh": "4b1f3796d1915ce97d0769cc13e711aa62c3c7430051ac075be802fc38e8de9a",

install.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@ run_hook() {
429429
python "${args[@]}"
430430
}
431431

432+
check_for_missing_migrations() {
433+
# Deployment must never invent schema history. Fail when model changes need
434+
# migration files that have not been generated and committed by developers.
435+
python manage.py makemigrations --check --dry-run --noinput \
436+
|| die "Model changes detected without committed Django migrations"
437+
}
438+
432439
bootstrap_application() {
433440
[[ -f "$INSTALL_PATH/manage.py" ]] || die "manage.py not found; run --stage first"
434441
[[ -x "$INSTALL_PATH/virtualenv/bin/python" ]] || die "virtualenv not found; run --stage first"
@@ -440,6 +447,7 @@ bootstrap_application() {
440447
python manage.py check --deploy
441448
local hook
442449
for hook in "${SCRIPT_BEFORE[@]}"; do run_hook "$hook"; done
450+
check_for_missing_migrations
443451
before_django_migrate "$ACTION" "$MIGRATION_MODULES"
444452
python manage.py migrate --noinput
445453
if [[ "$LOAD_TABLES" == "true" && "$SKIP_TABLES" == "false" ]]; then

0 commit comments

Comments
 (0)