52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
|
|
"""task system fields (headcount/exclusive/delivery_days/published_at/publisher_id/category_id) + task_categories
|
||
|
|
|
||
|
|
Revision ID: 0009_task_system_fields
|
||
|
|
Revises: f9f4eaef2e6f
|
||
|
|
Create Date: 2026-08-25
|
||
|
|
|
||
|
|
手写,仅含任务系统补全改动:tasks 加列 + 新建 task_categories 字典表。
|
||
|
|
(勿 autogenerate——上次误带 training_* 删除与 users 列改动。)
|
||
|
|
"""
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import sqlalchemy as sa
|
||
|
|
from alembic import op
|
||
|
|
|
||
|
|
|
||
|
|
revision = '0009_task_system_fields'
|
||
|
|
down_revision = 'f9f4eaef2e6f'
|
||
|
|
branch_labels = None
|
||
|
|
depends_on = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
# ---- task_categories 分类字典表 ----
|
||
|
|
op.create_table('task_categories',
|
||
|
|
sa.Column('id', sa.String(), nullable=False),
|
||
|
|
sa.Column('name', sa.String(), nullable=False, server_default=''),
|
||
|
|
sa.Column('sort', sa.Integer(), nullable=False, server_default='0'),
|
||
|
|
sa.Column('modes', sa.String(), nullable=False, server_default=''),
|
||
|
|
sa.Column('status', sa.String(), nullable=False, server_default='active'),
|
||
|
|
sa.PrimaryKeyConstraint('id')
|
||
|
|
)
|
||
|
|
op.create_index('ix_task_categories_name', 'task_categories', ['name'], unique=False)
|
||
|
|
|
||
|
|
# ---- tasks 加列 ----
|
||
|
|
op.add_column('tasks', sa.Column('category_id', sa.String(), nullable=True))
|
||
|
|
op.add_column('tasks', sa.Column('delivery_days', sa.Integer(), nullable=True))
|
||
|
|
op.add_column('tasks', sa.Column('headcount', sa.Integer(), nullable=True))
|
||
|
|
op.add_column('tasks', sa.Column('exclusive', sa.Boolean(), nullable=True))
|
||
|
|
op.add_column('tasks', sa.Column('published_at', sa.String(), nullable=True))
|
||
|
|
op.add_column('tasks', sa.Column('publisher_id', sa.String(), nullable=True))
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.drop_column('tasks', 'publisher_id')
|
||
|
|
op.drop_column('tasks', 'published_at')
|
||
|
|
op.drop_column('tasks', 'exclusive')
|
||
|
|
op.drop_column('tasks', 'headcount')
|
||
|
|
op.drop_column('tasks', 'delivery_days')
|
||
|
|
op.drop_column('tasks', 'category_id')
|
||
|
|
op.drop_index('ix_task_categories_name', table_name='task_categories')
|
||
|
|
op.drop_table('task_categories')
|