1f18d2ec87
- 新增 chinese_holidays 表,通过 timor.tech API 同步节假日数据 - 修正 holiday 字段解读:holiday=true → 休息日,holiday=false → 调休工作日 - 工作日 8:00-22:00 每小时爬取,周末/节假日/夜间自动跳过 - 新增 /api/v1/holidays/sync 和 /api/v1/holidays/today 接口 - 企微菜单新增「同步节假日」按钮,支持手动触发同步
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""add_chinese_holidays_table
|
|
|
|
Revision ID: 1f59799a5083
|
|
Revises: eed20ee8cc26
|
|
Create Date: 2026-05-09 18:14:31.144256
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '1f59799a5083'
|
|
down_revision: Union[str, Sequence[str], None] = 'eed20ee8cc26'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
op.create_table(
|
|
'chinese_holidays',
|
|
sa.Column('date', sa.Date(), nullable=False),
|
|
sa.Column('is_workday', sa.Boolean(), nullable=False, server_default='true'),
|
|
sa.Column('year', sa.Integer(), nullable=False),
|
|
sa.Column('description', sa.String(length=100), nullable=False, server_default=''),
|
|
sa.PrimaryKeyConstraint('date'),
|
|
)
|
|
op.create_index('idx_chinese_holidays_year', 'chinese_holidays', ['year'])
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
op.drop_index('idx_chinese_holidays_year', table_name='chinese_holidays')
|
|
op.drop_table('chinese_holidays')
|