feat(db): F3a prompt_templates 表 + 迁移
新增 PromptTemplate 模型(UuidPk+CreatedAt+Base;owner_id stub、title、body、 category、tool_key)+ alembic 迁移。alembic check 无漂移;ruff/mypy packages/db 干净。
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
"""prompt_templates table
|
||||
|
||||
Revision ID: 59a9198d4604
|
||||
Revises: d3e4f5a6b7c8
|
||||
Create Date: 2026-06-23 20:10:37.869872
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "59a9198d4604"
|
||||
down_revision: str | None = "d3e4f5a6b7c8"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"prompt_templates",
|
||||
sa.Column("owner_id", sa.Uuid(), nullable=False),
|
||||
sa.Column("title", sa.Text(), nullable=False),
|
||||
sa.Column("body", sa.Text(), nullable=False),
|
||||
sa.Column("category", sa.Text(), nullable=True),
|
||||
sa.Column("tool_key", sa.Text(), nullable=True),
|
||||
sa.Column("id", sa.Uuid(), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["owner_id"],
|
||||
["users.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_prompt_templates_owner_id"), "prompt_templates", ["owner_id"], unique=False
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_prompt_templates_owner_id"), table_name="prompt_templates")
|
||||
op.drop_table("prompt_templates")
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user