Files
EnuivTools/backend/alembic/versions/0007_study_start_day.py
T

31 lines
869 B
Python

"""定时开始日限制为每月 5 到 25 号,超出范围的旧值改为 8 号。"""
from alembic import op
import sqlalchemy as sa
revision = "0007_study_start_day"
down_revision = "0006_employee_width"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.execute("UPDATE accounts SET study_start_day = 8 WHERE study_start_day < 5 OR study_start_day > 25")
with op.batch_alter_table("accounts") as batch:
batch.alter_column(
"study_start_day",
existing_type=sa.Integer(),
existing_nullable=False,
server_default="8",
)
def downgrade() -> None:
with op.batch_alter_table("accounts") as batch:
batch.alter_column(
"study_start_day",
existing_type=sa.Integer(),
existing_nullable=False,
server_default="1",
)