-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix role instantiation * closes inveniosoftware/invenio-app-rdm#2186 Co-authored-by: jrcastro2 <[email protected]>
- Loading branch information
Showing
7 changed files
with
124 additions
and
14 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
invenio_access/alembic/842a62b56e60_change_fk_accountsrole_to_string_downgrade.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 @@ | ||
# This file is part of Invenio. | ||
# Copyright (C) 2016-2018 CERN. | ||
# | ||
# Invenio is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Change FK AccountsRole to string (downgrade recipe).""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "842a62b56e60" | ||
down_revision = "04480be1593e" | ||
branch_labels = () | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade database.""" | ||
pass | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade database.""" | ||
op.alter_column( | ||
"access_actionsroles", | ||
"role_id", | ||
existing_type=sa.String(80), | ||
type_=sa.Integer, | ||
postgresql_using="role_id::integer", | ||
) | ||
op.create_foreign_key( | ||
op.f("fk_access_actionsroles_role_id_accounts_role"), | ||
"access_actionsroles", | ||
"accounts_role", | ||
["role_id"], | ||
["id"], | ||
ondelete="CASCADE", | ||
) |
47 changes: 47 additions & 0 deletions
47
invenio_access/alembic/f9843093f686_change_fk_accountsrole_to_string_upgrade.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,47 @@ | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2016-2018 CERN. | ||
# | ||
# Invenio is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Change FK AccountsRole to string (upgrade recipe). | ||
This recipe only contains the upgrade because as it directly depends on invenio-accounts recipe. That recipe is in | ||
charge of deleting all the constraints on the role_id, including foreign keys using the role_id declared in this module. | ||
Therefore, when in order to downgrade we need to split the recipes to be able to first execute the recipe in | ||
invenio-accounts (f2522cdd5fcd) and after that we can execute the downgrade recipe (842a62b56e60). | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "f9843093f686" | ||
down_revision = ("f2522cdd5fcd", "842a62b56e60") # Depends on invenio-accounts revision id (f2522cdd5fcd) | ||
branch_labels = () | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade database.""" | ||
op.alter_column( | ||
"access_actionsroles", | ||
"role_id", | ||
existing_type=sa.Integer, | ||
type_=sa.String(80), | ||
postgresql_using="role_id::integer", | ||
) | ||
op.create_foreign_key( | ||
op.f("fk_access_actionsroles_role_id_accounts_role"), | ||
"access_actionsroles", | ||
"accounts_role", | ||
["role_id"], | ||
["id"], | ||
ondelete="CASCADE", | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade database.""" | ||
pass |
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
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