Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 1.09 KB

File metadata and controls

31 lines (23 loc) · 1.09 KB

Database migrations (Alembic)

The database URL is read automatically from backend.config.settings (your .env), so commands need no extra flags. Run from the project root.

Common commands

# Apply all migrations (creates the schema on a fresh DB)
alembic upgrade head

# Autogenerate a migration after changing models in backend/database/models.py
alembic revision --autogenerate -m "add widget table"

# Roll back one revision
alembic downgrade -1

# Show current revision
alembic current

Notes

  • Baseline (0001_initial) builds the whole schema from the SQLAlchemy models using create_all (idempotent) and enables the pgvector extension on PostgreSQL.
  • The app also calls create_all on startup for dev convenience. Because both are idempotent they coexist. For a strict migration-driven prod flow, run alembic upgrade head against a fresh DB; if the app already created the tables, run alembic stamp head once to mark them as migrated.
  • pgvector requires PostgreSQL — migrations targeting SQLite will skip the extension and the document_chunks vector table.