This commit is contained in:
949036910@qq.com
2026-05-30 12:46:17 +08:00
parent d9c4e04d66
commit d6fefd6138
7 changed files with 138 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ from sqlalchemy.ext.asyncio import async_engine_from_config
from app.config import get_settings
from app.database import Base
from app.models import CardKey, DesktopConfig, Oem, User # noqa: F401 — 注册元数据
from app.models import CardKey, Config, DesktopConfig, Oem, User # noqa: F401 — 注册元数据
config = context.config
settings = get_settings()

View File

@@ -0,0 +1,41 @@
"""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")