followed article here for guidance: https://arunanshub.hashnode.dev/using-sqlmodel-with-alembic#heading-sql-constraint-naming-convention mirrored on my readeck: https://readeck.yuno.jack-case.pro/bookmarks/9ay79PHux348cgQBnA86UC
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""initial
|
|
|
|
Revision ID: 72dcd047d7bf
|
|
Revises:
|
|
Create Date: 2025-10-17 20:10:04.230321
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel.sql.sqltypes
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '72dcd047d7bf'
|
|
down_revision: Union[str, Sequence[str], None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('domain',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('domain_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_domain'))
|
|
)
|
|
op.create_index(op.f('ix_domain_domain_name'), 'domain', ['domain_name'], unique=True)
|
|
op.create_table('path',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('path', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('domain_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], name=op.f('fk_path_domain_id_domain')),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_path'))
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('path')
|
|
op.drop_index(op.f('ix_domain_domain_name'), table_name='domain')
|
|
op.drop_table('domain')
|
|
# ### end Alembic commands ###
|