Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: fail on errors in database migrations (#4252)

Steffen Schmitzfc94c02058e3
diff --git a/web/entrypoint.sh b/web/entrypoint.sh
index ac4e384c06..642df79f73 100644
--- a/web/entrypoint.sh
+++ b/web/entrypoint.sh
@@ -19,23 +19,35 @@ if [ -z "$DIRECT_URL" ]; then
export DIRECT_URL=$DATABASE_URL
fi
-# Always execute the scripts, except when disabled.
+# Always execute the postgres migration, except when disabled.
if [ "$LANGFUSE_AUTO_POSTGRES_MIGRATION_DISABLED" != "true" ]; then
prisma db execute --url "$DIRECT_URL" --file "./packages/shared/scripts/cleanup.sql"
# Apply migrations
prisma migrate deploy --schema=./packages/shared/prisma/schema.prisma
+fi
+status=$?
+
+# If migration fails (returns non-zero exit status), exit script with that status
+if [ $status -ne 0 ]; then
+ echo "Applying database migrations failed. This is mostly caused by the database being unavailable."
+ echo "Exiting..."
+ exit $status
+fi
+# Execute the Clickhouse migration, except when disabled.
+# TODO: For now, we use the same flag as for the Postgres migration.
+if [ "$LANGFUSE_AUTO_POSTGRES_MIGRATION_DISABLED" != "true" ]; then
# Apply Clickhouse migrations
cd ./packages/shared
sh ./clickhouse/scripts/up.sh
+ status=$?
cd ../../
fi
-status=$?
# If migration fails (returns non-zero exit status), exit script with that status
if [ $status -ne 0 ]; then
- echo "Applying database migrations failed. This is mostly caused by the database being unavailable."
+ echo "Applying clickhouse migrations failed. This is mostly caused by the database being unavailable."
echo "Exiting..."
exit $status
fi