feat(migrations): T11 setup Alembic and initial schema migration
- Initialize Alembic with alembic init alembic - Configure alembic.ini to use DATABASE_URL from environment - Configure alembic/env.py to import Base and models metadata - Generate initial migration: c92fc544a483_initial_schema - Migration creates all 4 tables: users, api_keys, api_tokens, usage_stats - Migration includes all indexes, constraints, and foreign keys - Test upgrade/downgrade cycle works correctly Alembic commands: - alembic upgrade head - alembic downgrade -1 - alembic revision --autogenerate -m 'message' Tests: 13 migration tests pass
This commit is contained in:
28
alembic/script.py.mako
Normal file
28
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"}
|
||||
Reference in New Issue
Block a user