🗃️ alter fields to not null, fix typing

This commit is contained in:
felinae98 2023-03-09 19:13:46 +08:00
parent 88bb1d3698
commit 45b4ac3988
2 changed files with 61 additions and 2 deletions

View File

@ -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,

View File

@ -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 ###