Files
MoviePilot/database/versions/262735d025da_2_0_1.py
T

80 lines
1.9 KiB
Python

"""2.0.1
Revision ID: 262735d025da
Revises: 294b007932ef
Create Date: 2024-09-11 08:07:02.753307
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '262735d025da'
down_revision = '294b007932ef'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# 初始化消息通知范围
systemconfig = sa.table(
"systemconfig",
sa.column("key", sa.String()),
sa.column("value", sa.JSON()),
)
connection = op.get_bind()
key = "NotificationSwitchs"
row = connection.execute(
sa.select(systemconfig.c.value).where(systemconfig.c.key == key)
).first()
if not row or not row[0]:
value = [
{
'type': '资源下载',
'action': 'all',
},
{
'type': '整理入库',
'action': 'all',
},
{
'type': '订阅',
'action': 'all',
},
{
'type': '站点',
'action': 'admin',
},
{
'type': '媒体服务器',
'action': 'admin',
},
{
'type': '手动处理',
'action': 'admin',
},
{
'type': '插件',
'action': 'admin',
},
{
'type': '其它',
'action': 'admin',
},
]
if row:
connection.execute(
systemconfig.update().where(systemconfig.c.key == key).values(
value=value
)
)
else:
connection.execute(systemconfig.insert().values(key=key, value=value))
# ### end Alembic commands ###
def downgrade() -> None:
pass