diff --git a/backend/lcfs/prestart.sh b/backend/lcfs/prestart.sh index 952f220c6..3fe3f9cda 100755 --- a/backend/lcfs/prestart.sh +++ b/backend/lcfs/prestart.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash -echo "running prestart.sh from $(pwd)" +echo "Running prestart.sh from $(pwd)" + +# Check for Alembic head conflicts +HEAD_COUNT=$(poetry run alembic heads | wc -l) +if [ "$HEAD_COUNT" -gt 1 ]; then + echo "Alembic head conflict detected: Multiple migration heads present." + exit 1 +fi # Apply base database migrations echo "Applying base migrations." @@ -23,5 +30,4 @@ if [ $? -ne 0 ]; then fi echo "Migrations and seeding completed successfully." - -echo "done running prestart.sh from $(pwd)" +echo "Done running prestart.sh from $(pwd)" diff --git a/backend/lcfs/start.sh b/backend/lcfs/start.sh index b84880611..7e19eb1ef 100755 --- a/backend/lcfs/start.sh +++ b/backend/lcfs/start.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Enable strict error handling +set -e + # Wait for the database to be ready ./wait-for-it.sh $LCFS_DB_HOST:5432 --timeout=30