46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""工号列加长到 64,并去掉只写不读的课程数量。"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "0006_employee_width"
|
|
down_revision = "0005_password_login_at"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
with op.batch_alter_table("accounts") as batch:
|
|
batch.alter_column(
|
|
"employee_id",
|
|
existing_type=sa.String(length=32),
|
|
type_=sa.String(length=64),
|
|
existing_nullable=False,
|
|
)
|
|
with op.batch_alter_table("course_sync") as batch:
|
|
batch.alter_column(
|
|
"last_employee_id",
|
|
existing_type=sa.String(length=32),
|
|
type_=sa.String(length=64),
|
|
existing_nullable=False,
|
|
)
|
|
batch.drop_column("course_count")
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table("course_sync") as batch:
|
|
batch.add_column(sa.Column("course_count", sa.Integer(), nullable=False, server_default="0"))
|
|
batch.alter_column(
|
|
"last_employee_id",
|
|
existing_type=sa.String(length=64),
|
|
type_=sa.String(length=32),
|
|
existing_nullable=False,
|
|
)
|
|
with op.batch_alter_table("accounts") as batch:
|
|
batch.alter_column(
|
|
"employee_id",
|
|
existing_type=sa.String(length=64),
|
|
type_=sa.String(length=32),
|
|
existing_nullable=False,
|
|
)
|