From 91b8a9e0bb7955cd8afe479be4fa02263e6a5c87 Mon Sep 17 00:00:00 2001 From: Stanislav Novosad Date: Fri, 21 Nov 2025 09:57:14 -0700 Subject: [PATCH] Allow running Skyvern on newer DB version when explicitly requested (#3955) --- entrypoint-skyvern.sh | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) mode change 100644 => 100755 entrypoint-skyvern.sh diff --git a/entrypoint-skyvern.sh b/entrypoint-skyvern.sh old mode 100644 new mode 100755 index d0eb8ba0..24cb9818 --- a/entrypoint-skyvern.sh +++ b/entrypoint-skyvern.sh @@ -2,9 +2,33 @@ set -e -# check alembic -alembic upgrade head -alembic check +# Set ALLOWED_SKIP_DB_MIGRATION_VERSION env var to the DB version you want to allow (select * from alembic_version) +# If current DB matches this version, migrations will be skipped. Use at your own risk. +ALLOWED_SKIP_DB_MIGRATION_VERSION=${ALLOWED_SKIP_DB_MIGRATION_VERSION:-} + +# Run migrations by default +run_migration=true + +if [ -n "$ALLOWED_SKIP_DB_MIGRATION_VERSION" ]; then + current_version=$(alembic current 2>&1 | grep -Eo "[0-9a-f]{12,}" | tail -n 1 || echo "") + echo "Current DB version: $current_version" + + if [ "$current_version" = "$ALLOWED_SKIP_DB_MIGRATION_VERSION" ]; then + echo "⚠️ WARNING: Skipping database migrations" + echo "⚠️ DB is at version $current_version which matches ALLOWED_SKIP_DB_MIGRATION_VERSION" + echo "⚠️ Running older code against newer database schema" + echo "⚠️ Beware of compatibility risks!" + run_migration=false + else + echo "Current DB version ($current_version) does not match ALLOWED_SKIP_DB_MIGRATION_VERSION ($ALLOWED_SKIP_DB_MIGRATION_VERSION)" + fi +fi + +if [ "$run_migration" = true ]; then + echo "Running database migrations..." + alembic upgrade head + alembic check +fi if [ ! -f ".streamlit/secrets.toml" ]; then echo "Creating organization and API token..."