From 45b4ac39880e13125663fd7cf57571d6333edcd4 Mon Sep 17 00:00:00 2001 From: felinae98 <731499577@qq.com> Date: Thu, 9 Mar 2023 19:13:46 +0800 Subject: [PATCH] :card_file_box: alter fields to not null, fix typing --- nonebot_bison/admin_page/api.py | 4 +- .../aceef470d69c_alter_fields_not_null.py | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 nonebot_bison/config/migrations/aceef470d69c_alter_fields_not_null.py diff --git a/nonebot_bison/admin_page/api.py b/nonebot_bison/admin_page/api.py index 8cb485f..8b3f554 100644 --- a/nonebot_bison/admin_page/api.py +++ b/nonebot_bison/admin_page/api.py @@ -137,8 +137,8 @@ async def get_subs_info(jwt_obj: dict = Depends(get_jwt_obj)) -> SubscribeResp: lambda sub: SubscribeConfig( platformName=sub.target.platform_name, targetName=sub.target.target_name, - cats=sub.categories, # type: ignore - tags=sub.tags, # type: ignore + cats=sub.categories, + tags=sub.tags, target=sub.target.target, ), raw_subs, diff --git a/nonebot_bison/config/migrations/aceef470d69c_alter_fields_not_null.py b/nonebot_bison/config/migrations/aceef470d69c_alter_fields_not_null.py new file mode 100644 index 0000000..b55175e --- /dev/null +++ b/nonebot_bison/config/migrations/aceef470d69c_alter_fields_not_null.py @@ -0,0 +1,59 @@ +"""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 ###