Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,16 @@ if [ "$DB_AUTO_MIGRATE" = "true" ]; then
# URL scheme. The pgx/v5 driver registers "pgx5" only. See issue #1849.
DB_URL="pgx5://${DB_USER}:${ENCODED_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=${DB_SSL_MODE}"

migrate -path "$DB_MIGRATIONS_PATH" -database "$DB_URL" up 2>&1
MIGRATE_EXIT_CODE=$?
if [ $MIGRATE_EXIT_CODE -eq 0 ]; then
echo " ✅ Migrations completed successfully"
elif [ $MIGRATE_EXIT_CODE -eq 1 ]; then
# Exit code 1 means "no change", which is okay
echo " ℹ️ No new migrations to apply"
else
# `|| MIGRATE_EXIT_CODE=$?` keeps the failure out of errexit so the
# diagnostic below runs. golang-migrate exits 0 on "no change", so any
# non-zero status is a real failure.
MIGRATE_EXIT_CODE=0
migrate -path "$DB_MIGRATIONS_PATH" -database "$DB_URL" up 2>&1 || MIGRATE_EXIT_CODE=$?
if [ "$MIGRATE_EXIT_CODE" -ne 0 ]; then
echo " ❌ Migration failed with exit code $MIGRATE_EXIT_CODE"
exit $MIGRATE_EXIT_CODE
exit "$MIGRATE_EXIT_CODE"
fi
echo " ✅ Migrations completed successfully"
else
echo " ⚠️ Skipping migrations (DB_PASSWORD not available)"
echo " Application will handle migrations on first connection"
Expand Down
Loading