refactor: 重构 schemas 结构,统一枚举定义
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""converge schedule item status to active or archived
|
||||
|
||||
Revision ID: 202603250001
|
||||
Revises: 202603240001
|
||||
Create Date: 2026-03-25 10:00:00
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "202603250001"
|
||||
down_revision: Union[str, Sequence[str], None] = "202603240001"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE public.schedule_items
|
||||
SET status = 'archived'
|
||||
WHERE status IN ('completed', 'canceled')
|
||||
"""
|
||||
)
|
||||
op.execute(
|
||||
"""
|
||||
ALTER TABLE public.schedule_items
|
||||
DROP CONSTRAINT IF EXISTS chk_schedule_item_status
|
||||
"""
|
||||
)
|
||||
op.execute(
|
||||
"""
|
||||
ALTER TABLE public.schedule_items
|
||||
ADD CONSTRAINT chk_schedule_item_status
|
||||
CHECK (status IN ('active', 'archived'))
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute(
|
||||
"""
|
||||
ALTER TABLE public.schedule_items
|
||||
DROP CONSTRAINT IF EXISTS chk_schedule_item_status
|
||||
"""
|
||||
)
|
||||
op.execute(
|
||||
"""
|
||||
ALTER TABLE public.schedule_items
|
||||
ADD CONSTRAINT chk_schedule_item_status
|
||||
CHECK (status IN ('active', 'completed', 'canceled', 'archived'))
|
||||
"""
|
||||
)
|
||||
Reference in New Issue
Block a user