feat(backend): add Alembic migrations
- Add alembic 1.14 to dependencies (uv sync → 1.18.4 installed) - Configure alembic/env.py: loads DATABASE_URL from env, imports all SQLModel models so metadata is fully populated for autogenerate - Generate initial migration (c2d626a2b36c) covering all 9 tables: products, product_inventory, medication_entries, medication_usages, lab_results, routines, routine_steps, grooming_schedule, skin_condition_snapshots — with all indexes and constraints - Add ExecStartPre to innercontext.service: runs alembic upgrade head before uvicorn starts (idempotent, safe on every restart) - Update DEPLOYMENT.md: add migration step to backend setup and update flow; document alembic stamp head for existing installations Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
95fbdeb212
commit
3c1dcbeb06
9 changed files with 577 additions and 2 deletions
28
backend/alembic/script.py.mako
Normal file
28
backend/alembic/script.py.mako
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
${downgrades if downgrades else "pass"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue