54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""add community accounts
|
|
|
|
Revision ID: a91b7c4d2f10
|
|
Revises: 8d3f0c61bb21
|
|
Create Date: 2026-04-21 11:30:00.000000
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = "a91b7c4d2f10"
|
|
down_revision = "8d3f0c61bb21"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"community_account",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.String(length=120), nullable=False),
|
|
sa.Column("slug", sa.String(length=120), nullable=False),
|
|
sa.Column("description", sa.Text(), nullable=True),
|
|
sa.Column("account_type", sa.String(length=20), nullable=False),
|
|
sa.Column("linked_account_slug", sa.String(length=120), nullable=True),
|
|
sa.Column("sort_order", sa.Integer(), nullable=False),
|
|
sa.Column("is_active", sa.Boolean(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("name"),
|
|
sa.UniqueConstraint("slug"),
|
|
)
|
|
|
|
with op.batch_alter_table("category", schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column("community_account_id", sa.Integer(), nullable=True))
|
|
batch_op.create_foreign_key(
|
|
"fk_category_community_account_id",
|
|
"community_account",
|
|
["community_account_id"],
|
|
["id"],
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table("category", schema=None) as batch_op:
|
|
batch_op.drop_constraint("fk_category_community_account_id", type_="foreignkey")
|
|
batch_op.drop_column("community_account_id")
|
|
|
|
op.drop_table("community_account")
|