gitscope
← marzneshin / v0.7.2 / app/db/migrations/versions/20241215_c9cab0432029_implement_host_chains.py
https://dev.kronoz.win/r/marzneshin.git
app/db/migrations/versions/20241215_c9cab0432029_implement_host_chains.py · Python
Blame Raw
 1"""implement host chains
 2
 3Revision ID: 982867b533e6
 4Revises: 79271458a973
 5Create Date: 2024-12-15 04:27:44.704707
 6
 7"""
 8
 9import sqlalchemy as sa
10from alembic import op
11
12# revision identifiers, used by Alembic.
13revision = "982867b533e6"
14down_revision = "79271458a973"
15branch_labels = None
16depends_on = None
17
18
19def upgrade() -> None:
20    # ### commands auto generated by Alembic - please adjust! ###
21    op.create_table(
22        "host_chains",
23        sa.Column("host_id", sa.Integer(), nullable=False),
24        sa.Column("chained_host_id", sa.Integer(), nullable=True),
25        sa.Column("seq", sa.Integer(), nullable=False),
26        sa.ForeignKeyConstraint(
27            ["chained_host_id"],
28            ["hosts.id"],
29        ),
30        sa.ForeignKeyConstraint(
31            ["host_id"],
32            ["hosts.id"],
33        ),
34        sa.PrimaryKeyConstraint("host_id", "seq"),
35    )
36    # ### end Alembic commands ###
37
38
39def downgrade() -> None:
40    # ### commands auto generated by Alembic - please adjust! ###
41    op.drop_table("host_chains")
42    # ### end Alembic commands ###