-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SET/RESET ROLE to migrations #82
Conversation
... Weirdness with SET ROLE/AUTH and SELECT current_user. See comments.
|
||
|
||
@pytest.mark.usefixtures('new_db_left') | ||
logger = logging.getLogger("tests") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: All changes in this file due to Black. No algorithmic changes.
tests/alembic_migrations/versions/v_4a2f1879293a_create_functions/conftest.py
Outdated
Show resolved
Hide resolved
This code has also been run successfully against a test database cloned from |
7bc7ee4
to
1916709
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Your explanations and documentation are clear. Good solution to a complicated problem, and heroic testing efforts. :)
Resolves #81
Note to reviewers: The vast majority of the changes in this PR are documentation, formatting, and test updates. The significant changes are confined to a few lines in:
pycds/alembic/extensions/operation_plugins.py
pycds/alembic/versions/4a2f1879293a_create_functions.py
pycds/util.py
This PR wraps revision 42af upgrade operations (create SPs) in a SET/RESET role pair to enable creating SPs with sufficiently high privilege in real databases.
The user in the tests is already at maximum privilege and I have not added infrastructure to create and use a lower-privileged user to test this aspect.Nominally, in tests, all migration operations are executed by a limited-privilege usertestuser
and privilege is only escalated to rolepcicdba
for the wrapped operations. However, it proved extremely difficult to verify whether the user was being set properly in tests, so this cannot quite be taken as definitive.