Files
yaoyaoai/alembic/versions/016_create_configs_table.py
949036910@qq.com d6fefd6138 11
2026-05-30 12:46:17 +08:00

42 lines
1.2 KiB
Python

"""create configs table"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "016"
down_revision: Union[str, None] = "015"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"configs",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("name", sa.String(length=64), nullable=False),
sa.Column("value", sa.Text(), nullable=False),
sa.Column("mark", sa.String(length=255), nullable=True),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=False,
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("name", name="uq_configs_name"),
)
op.create_index(op.f("ix_configs_name"), "configs", ["name"], unique=False)
def downgrade() -> None:
op.drop_index(op.f("ix_configs_name"), table_name="configs")
op.drop_table("configs")