11
This commit is contained in:
@@ -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()
|
||||
|
||||
41
alembic/versions/016_create_configs_table.py
Normal file
41
alembic/versions/016_create_configs_table.py
Normal 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")
|
||||
Reference in New Issue
Block a user