mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-05 03:38:36 +08:00
init users
This commit is contained in:
43
database/versions/3df653756eec_2_1_6.py
Normal file
43
database/versions/3df653756eec_2_1_6.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""2.1.6
|
||||
|
||||
Revision ID: 3df653756eec
|
||||
Revises: 486e56a62dcb
|
||||
Create Date: 2025-06-11 19:52:57.185355
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import sqlite
|
||||
|
||||
from app.db import SessionFactory
|
||||
from app.db.models import User
|
||||
from app.core.config import settings
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3df653756eec'
|
||||
down_revision = '486e56a62dcb'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with SessionFactory() as db:
|
||||
# 所有用户
|
||||
users = User.list(db)
|
||||
for user in users:
|
||||
if user.name == settings.SUPERUSER:
|
||||
continue
|
||||
if not user.permissions:
|
||||
user.permissions = {
|
||||
"discovery": True,
|
||||
"search": True,
|
||||
"subscribe": True,
|
||||
"manage": False,
|
||||
}
|
||||
user.update(db)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
Reference in New Issue
Block a user