Skip to content

Commit

Permalink
Add in migration for edit user (#3255)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Feb 11, 2025
1 parent 07642a1 commit 09e7e7b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion auth-api/migrations/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Generic single-database configuration.

1. Add a new migration: /migrations poetry run alembic revision --autogenerate -m "migration message"
1. Add new migration: poetry run flask db revision, make sure DEPLOYMENT_ENV is set to 'migration' in your .env
29 changes: 29 additions & 0 deletions auth-api/migrations/versions/2025_02_11_1893ddb6d071_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Migration to add in new permission EDIT_USER for admin
Revision ID: 1893ddb6d071
Revises: 7425171449c9
Create Date: 2025-02-11 05:56:03.631513
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1893ddb6d071'
down_revision = '7425171449c9'
branch_labels = None
depends_on = None


def upgrade():
op.execute("""INSERT INTO permissions (membership_type_code, actions)
SELECT 'ADMIN', 'edit_user'
WHERE NOT EXISTS (
SELECT 1 FROM permissions
WHERE membership_type_code = 'ADMIN'
AND actions = 'edit_user'
);""")

def downgrade():
op.execute("delete from permissions where membership_type_code = 'ADMIN' and actions = 'edit_user'")

0 comments on commit 09e7e7b

Please sign in to comment.