mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
feat: add migration for public_sharing permissions
This commit is contained in:
parent
f18ba8e045
commit
148daa23e1
1 changed files with 66 additions and 0 deletions
|
|
@ -0,0 +1,66 @@
|
|||
"""Add public_sharing permissions to existing roles
|
||||
|
||||
Revision ID: 86
|
||||
Revises: 85
|
||||
Create Date: 2026-02-02
|
||||
|
||||
"""
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision = "86"
|
||||
down_revision = "85"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
connection = op.get_bind()
|
||||
|
||||
connection.execute(
|
||||
text(
|
||||
"""
|
||||
UPDATE search_space_roles
|
||||
SET permissions = array_append(permissions, 'public_sharing:view')
|
||||
WHERE name IN ('Editor', 'Viewer')
|
||||
AND NOT ('public_sharing:view' = ANY(permissions))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
connection.execute(
|
||||
text(
|
||||
"""
|
||||
UPDATE search_space_roles
|
||||
SET permissions = array_append(permissions, 'public_sharing:create')
|
||||
WHERE name = 'Editor'
|
||||
AND NOT ('public_sharing:create' = ANY(permissions))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
connection = op.get_bind()
|
||||
|
||||
connection.execute(
|
||||
text(
|
||||
"""
|
||||
UPDATE search_space_roles
|
||||
SET permissions = array_remove(permissions, 'public_sharing:view')
|
||||
WHERE name IN ('Editor', 'Viewer')
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
connection.execute(
|
||||
text(
|
||||
"""
|
||||
UPDATE search_space_roles
|
||||
SET permissions = array_remove(permissions, 'public_sharing:create')
|
||||
WHERE name = 'Editor'
|
||||
"""
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue