generated from coulomb/repo-seed
feat(db): init Alembic (async) + SQLAlchemy declarative base — T08
- alembic init -t async migrations - alembic.ini: dev fallback URL postgresql+asyncpg://…:5433/actcore; ACTCORE_DB_URL env var overrides at runtime; src/ added to sys.path - migrations/env.py: reads ACTCORE_DB_URL, wires target_metadata to Base.metadata - src/activity_core/db.py: DeclarativeBase subclass + make_engine() helper Tool choice: Alembic + SQLAlchemy[asyncio] (already declared in pyproject.toml). Migrations run with: ACTCORE_DB_URL=... alembic upgrade head Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
28
migrations/script.py.mako
Normal file
28
migrations/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"}
|
||||
Reference in New Issue
Block a user