53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""Make client object better
|
|
|
|
Revision ID: c251311b64c9
|
|
Revises: 37329d9b5437
|
|
Create Date: 2025-06-04 21:49:22.638698
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "c251311b64c9"
|
|
down_revision: Union[str, None] = "37329d9b5437"
|
|
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! ###
|
|
with op.batch_alter_table("client", schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column("version", sa.Integer(), nullable=False))
|
|
batch_op.add_column(sa.Column("is_active", sa.Boolean(), nullable=False))
|
|
batch_op.add_column(sa.Column("is_deleted", sa.Boolean(), nullable=False))
|
|
batch_op.add_column(
|
|
sa.Column("deleted_at", sa.DateTime(timezone=True), nullable=True)
|
|
)
|
|
batch_op.add_column(sa.Column("parent_id", sa.Uuid(), nullable=True))
|
|
batch_op.drop_constraint("uq_client_name")
|
|
batch_op.create_unique_constraint("uq_client_name_version", ["name", "version"])
|
|
batch_op.create_foreign_key(
|
|
"fk_client_parent", "client", ["parent_id"], ["id"], ondelete="SET NULL"
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table("client", schema=None) as batch_op:
|
|
batch_op.drop_constraint("fk_client_parent", type_="foreignkey")
|
|
batch_op.drop_constraint("uq_client_name_version", type_="unique")
|
|
batch_op.drop_column("parent_id")
|
|
batch_op.drop_column("deleted_at")
|
|
batch_op.drop_column("is_deleted")
|
|
batch_op.drop_column("is_active")
|
|
batch_op.drop_column("version")
|
|
# ### end Alembic commands ###
|