ai-dev-kit icon indicating copy to clipboard operation
ai-dev-kit copied to clipboard

deploy.sh does not include alembic migrations — tables never created on first deploy

Open sgarla opened this issue 9 months ago • 1 comments

Bug

scripts/deploy.sh copies server/, client/out/, app.yaml, and requirements.txt to the staging directory, but does not copy alembic/ or alembic.ini.

On app startup, run_migrations() searches for alembic.ini in these paths:

  • <app_root>/alembic.ini
  • /app/python/source_code/alembic.ini
  • ./alembic.ini

Since none of these exist in the deployed package, the migration is silently skipped. As a result, the database tables (projects, conversations, messages, project_backup, executions) are never created, and the app fails immediately on first use with:

psycopg.errors.UndefinedTable: relation "projects" does not exist

Steps to Reproduce

  1. Follow the deployment guide: create Lakebase, create app, add resource, configure app.yaml, run ./scripts/deploy.sh <app-name>
  2. Open the app URL
  3. Attempt to create a project → Error: Failed to create project

Fix

Add the following lines to the staging copy section of deploy.sh:

# Copy alembic migrations
cp alembic.ini "$STAGING_DIR/"
cp -r alembic "$STAGING_DIR/"

Workaround
Manually create the tables after first deploy by generating a Lakebase OAuth token and running create_tables() from a local Python session with LAKEBASE_PG_URL set.

sgarla avatar Feb 27 '26 04:02 sgarla

This appears to already be fixed on main. The current deploy.sh (lines 217-219) includes:

# Copy Alembic migrations
echo "  Copying Alembic migrations..."
cp alembic.ini "$STAGING_DIR/"
cp -r alembic "$STAGING_DIR/"

Could this issue be closed?

CheeYuTan avatar Mar 09 '26 11:03 CheeYuTan