- src/ 按域组织骨架,示例域 items 双后端实现(SQLAlchemy2.0 async / Beanie 2.x) - DB_BACKEND 环境变量切换,router 只依赖 Repo Protocol - alembic 迁移(含初始 items 迁移)、uv 依赖管理、ruff、pytest 异步测试 - Dockerfile + docker-compose(app/mysql/mongo) - AGENTS.md 重写为本模板开发规范;原最佳实践文档归档 docs/ - 验证:mongodb/mysql 双后端 pytest 全绿 + uvicorn 真实冒烟通过
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""init items table
|
|
|
|
Revision ID: 81076765be75
|
|
Revises:
|
|
Create Date: 2026-08-21 21:21:49.098436
|
|
"""
|
|
from collections.abc import Sequence
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision: str = '81076765be75'
|
|
down_revision: str | None = None
|
|
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('items',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('name', sa.String(length=128), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_items_name'), 'items', ['name'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_items_name'), table_name='items')
|
|
op.drop_table('items')
|
|
# ### end Alembic commands ###
|