Skip to content

Commit

Permalink
Merge pull request #1347 from bcgov/feat/hamed-prevent-startup-migrat…
Browse files Browse the repository at this point in the history
…ion-conflict-1228

Feat: Prevent Backend Startup on Alembic Migration Conflicts - 1228
  • Loading branch information
hamed-valiollahi authored Dec 5, 2024
2 parents 3219a4d + 011013f commit db5664f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions backend/lcfs/prestart.sh
Original file line number Diff line number Diff line change
@@ -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."
Expand All @@ -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)"
3 changes: 3 additions & 0 deletions backend/lcfs/start.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit db5664f

Please sign in to comment.