mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-05 19:36:43 +08:00
* 🎨 修改 nonebot_bison 目录位置 * auto fix by pre-commit hooks * 🚚 fix frontend build target * 🚚 use soft link * Revert "🚚 use soft link" This reverts commit de21f79d5ae1bd5515b04f42a4138cb25ddf3e62. * 🚚 modify dockerfile --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: felinae98 <731499577@qq.com>
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
"""alter_json_not_null
|
|
|
|
Revision ID: bd92923c218f
|
|
Revises: 5da28f6facb3
|
|
Create Date: 2023-03-02 14:04:16.492133
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.automap import automap_base
|
|
from sqlalchemy.orm import Session
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "bd92923c218f"
|
|
down_revision = "5da28f6facb3"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def set_default_value():
|
|
Base = automap_base()
|
|
Base.prepare(autoload_with=op.get_bind())
|
|
Subscribe = Base.classes.nonebot_bison_subscribe
|
|
with Session(op.get_bind()) as session:
|
|
select_statement = select(Subscribe)
|
|
results = session.scalars(select_statement)
|
|
for subscribe in results:
|
|
if subscribe.categories is None:
|
|
subscribe.categories = []
|
|
if subscribe.tags is None:
|
|
subscribe.tags = []
|
|
session.commit()
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
set_default_value()
|
|
with op.batch_alter_table("nonebot_bison_subscribe", schema=None) as batch_op:
|
|
batch_op.alter_column("categories", existing_type=sa.JSON(), nullable=False)
|
|
batch_op.alter_column("tags", existing_type=sa.JSON(), nullable=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table("nonebot_bison_subscribe", schema=None) as batch_op:
|
|
batch_op.alter_column("tags", existing_type=sa.JSON(), nullable=True)
|
|
batch_op.alter_column("categories", existing_type=sa.JSON(), nullable=True)
|
|
|
|
# ### end Alembic commands ###
|