Schema & migrations
init_db() runs CREATE TABLE IF NOT EXISTS on startup. For schema changes, use Alembic.
Code example
Base.metadata.create_all(engine) # creates all tables # Alembic for migrations (not used in this app, but standard): # alembic revision --autogenerate -m 'add email col' # alembic upgrade head
How it works
Schema management has two levels. (1) `Base.metadata.create_all(engine)` creates every table that doesn't exist yet — perfect for fresh setups but it can't alter existing tables. (2) For production schema evolution, use Alembic: it generates migration scripts that ALTER tables in a controlled way. OpenBenchML uses the simple approach because the schema is stable; if you add a column, you'd drop the SQLite file in dev and let it recreate. In prod (Supabase Postgres) you'd run Alembic.
🔍 Where this is used in OpenBenchML
app/main.py lifespan calls init_db() → Base.metadata.create_all() at startup.