Skip to content

Commit de3192c

Browse files
mikemolinetclaude
andcommitted
ci(test): replace alembic with Base.metadata.create_all (matches cueapi-core conftest)
First push failed because OSS migration set ends at 023 while the User model declares an `api_key_encrypted` column with no migration backing it. That's a parity drift in cueapi-core (private migration 019 in the hosted repo includes the column; the OSS port renamed/replaced it with the alert-webhook bits but kept the column on the model). `alembic upgrade head` produced a schema missing that column → register endpoint 500'd on the User SELECT. Switch the CI bootstrap to model-driven schema init via `Base.metadata.create_all`, which is the exact pattern cueapi-core's own `tests/conftest.py` uses (and which is robust to model/migration drift because the model is the source of truth for tests). Imports the same model list as conftest so all tables register before create_all runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 88e41e3 commit de3192c

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/feature-to-main.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,35 @@ jobs:
5353
pip install -r cueapi-core/requirements.txt
5454
pip install -e .
5555
56-
- name: Apply migrations to test DB
56+
- name: Initialize test DB schema (model-driven, matches cueapi-core/tests/conftest.py)
5757
working-directory: cueapi-core
5858
env:
5959
DATABASE_URL: postgresql+asyncpg://runner@localhost:5432/cueapi_test
6060
REDIS_URL: redis://localhost:6379
6161
SESSION_SECRET: test-session-secret-32-chars-minimum!!
6262
ENV: test
6363
RESEND_API_KEY: ""
64-
run: python -m alembic upgrade head
64+
run: |
65+
python <<'PY'
66+
import asyncio
67+
from sqlalchemy.ext.asyncio import create_async_engine
68+
from app.config import settings
69+
from app.database import Base
70+
# Import all models so Base.metadata sees them (mirrors tests/conftest.py).
71+
from app.models import ( # noqa: F401
72+
Alert, Cue, DispatchOutbox, Execution, UsageMonthly, User, Worker, DeviceCode,
73+
Agent, Message, UsageMessagesMonthly,
74+
)
75+
76+
async def _init():
77+
engine = create_async_engine(settings.DATABASE_URL)
78+
async with engine.begin() as conn:
79+
await conn.run_sync(Base.metadata.create_all)
80+
await engine.dispose()
81+
82+
asyncio.run(_init())
83+
print("Schema initialized via Base.metadata.create_all")
84+
PY
6585
6686
- name: Start cueapi-core API in background
6787
working-directory: cueapi-core

0 commit comments

Comments
 (0)