nonebot-bison/nonebot_bison/config/migrations/aceef470d69c_alter_fields_not_null.py
2023-03-09 19:25:29 +08:00

60 lines
2.3 KiB
Python

"""alter fields not null
Revision ID: aceef470d69c
Revises: bd92923c218f
Create Date: 2023-03-09 19:10:42.168133
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "aceef470d69c"
down_revision = "bd92923c218f"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table(
"nonebot_bison_scheduletimeweight", schema=None
) as batch_op:
batch_op.alter_column("target_id", existing_type=sa.INTEGER(), nullable=False)
batch_op.alter_column("start_time", existing_type=sa.TIME(), nullable=False)
batch_op.alter_column("end_time", existing_type=sa.TIME(), nullable=False)
batch_op.alter_column("weight", existing_type=sa.INTEGER(), nullable=False)
with op.batch_alter_table("nonebot_bison_subscribe", schema=None) as batch_op:
batch_op.alter_column("target_id", existing_type=sa.INTEGER(), nullable=False)
batch_op.alter_column("user_id", existing_type=sa.INTEGER(), nullable=False)
with op.batch_alter_table("nonebot_bison_target", schema=None) as batch_op:
batch_op.alter_column(
"default_schedule_weight", existing_type=sa.INTEGER(), nullable=False
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("nonebot_bison_target", schema=None) as batch_op:
batch_op.alter_column(
"default_schedule_weight", existing_type=sa.INTEGER(), nullable=True
)
with op.batch_alter_table("nonebot_bison_subscribe", schema=None) as batch_op:
batch_op.alter_column("user_id", existing_type=sa.INTEGER(), nullable=True)
batch_op.alter_column("target_id", existing_type=sa.INTEGER(), nullable=True)
with op.batch_alter_table(
"nonebot_bison_scheduletimeweight", schema=None
) as batch_op:
batch_op.alter_column("weight", existing_type=sa.INTEGER(), nullable=True)
batch_op.alter_column("end_time", existing_type=sa.TIME(), nullable=True)
batch_op.alter_column("start_time", existing_type=sa.TIME(), nullable=True)
batch_op.alter_column("target_id", existing_type=sa.INTEGER(), nullable=True)
# ### end Alembic commands ###