Skip to content

Commit

Permalink
Run apply migrations on prod app start
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarvajal committed Jul 31, 2024
1 parent 3b70ba4 commit 685f273
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/sh

apply_migrations() {
echo "Applying database migrations..."
if ! alembic upgrade head; then
echo "Error applying migrations"
exit 1
fi
}

if [ "$ENV" = "dev" ]; then
echo "Starting FastAPI in development mode with SSL..."
SSL_KEYFILE="./certs/key.pem"
Expand All @@ -11,6 +19,9 @@ else

# Set the default environment to production if not specified
ENV=${ENV:-production}

# Apply database migrations
apply_migrations

echo "Starting FastAPI in production mode..."
uvicorn app.main:app --host 0.0.0.0 --port 8000
Expand Down

0 comments on commit 685f273

Please sign in to comment.