-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3893 from hove-io/feat_avoid_pg_authentification_…
…for_bad_token Feat avoid pg authentification for bad token
- Loading branch information
Showing
5 changed files
with
69 additions
and
19 deletions.
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
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
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
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
40 changes: 40 additions & 0 deletions
40
source/tyr/migrations/versions/04f9b89e3ef5_add_no_access_in_user_type.py
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,40 @@ | ||
"""Add a new type no_access in user_type | ||
Revision ID: 04f9b89e3ef5 | ||
Revises: 75681b9c74aa | ||
Create Date: 2022-12-30 11:23:58.436438 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '04f9b89e3ef5' | ||
down_revision = '75681b9c74aa' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
new_options = ('with_free_instances', 'without_free_instances', 'super_user', 'no_access') | ||
old_type = sa.Enum('with_free_instances', 'without_free_instances', 'super_user', name='user_type') | ||
new_type = sa.Enum(*new_options, name='user_type') | ||
tmp_type = sa.Enum(*new_options, name='_user_type') | ||
|
||
|
||
def upgrade(): | ||
op.execute("COMMIT") | ||
op.execute("ALTER TYPE user_type ADD VALUE 'no_access'") | ||
op.execute( | ||
'INSERT INTO "user"(login, email, type) values(\'user_without_access\', \'[email protected]\', \'no_access\')' | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.execute('DELETE FROM "user" where type = \'no_access\'') | ||
tmp_type.create(op.get_bind(), checkfirst=False) | ||
op.execute('ALTER TABLE "user" ALTER COLUMN type DROP DEFAULT') | ||
op.execute('ALTER TABLE "user" ALTER COLUMN type TYPE _user_type USING type::text::_user_type') | ||
new_type.drop(op.get_bind(), checkfirst=False) | ||
|
||
old_type.create(op.get_bind(), checkfirst=False) | ||
op.execute('ALTER TABLE "user" ALTER COLUMN type TYPE user_type USING type::text::user_type') | ||
op.execute('ALTER TABLE "user" ALTER COLUMN type SET DEFAULT \'with_free_instances\'') | ||
tmp_type.drop(op.get_bind(), checkfirst=False) |