-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in migration for edit user (#3255)
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'") |