Introduce Alembic at v1. Migrations live inside the package (decnet/web/db/migrations) so they ship with installs; alembic.ini at the repo root drives the CLI. env.py is async and dual-backend, selecting the engine from DECNET_DB_TYPE (mirroring db/factory.py) and reusing the app's own connection when run programmatically. The baseline captures all 39 tables. _BIG_TEXT round-trips as Text().with_variant(MEDIUMTEXT, 'mysql'), so both backends get the right column type from the migration. kd_digraph_simhash gains a sqlite BLOB variant: BINARY(8) reflects as NUMERIC on SQLite and would otherwise trip 'alembic check' forever.
30 lines
790 B
Mako
30 lines
790 B
Mako
"""${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
|
|
import sqlmodel # SQLModel column types (AutoString, …) referenced by autogenerate
|
|
${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"}
|
|
|