-
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
8 changed files
with
108 additions
and
36 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
invenio_access/alembic/842a62b56e60_change_fk_accountsrole_to_string.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,64 @@ | ||
# 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.""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from invenio_accounts.alembic.f2522cdd5fcd_change_accountsrole_primary_key_to_ import ( | ||
downgrade as accounts_downgrade, | ||
) | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "842a62b56e60" | ||
down_revision = "04480be1593e" | ||
branch_labels = () | ||
depends_on = "f2522cdd5fcd" # This is a revision from invenio-accounts, it's needed because in this recipe we re-create | ||
# a foreign key that uses a primary key (role_id) which type is modified in the pointed revision. | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade database.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
|
||
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.""" | ||
# When downgrading we need to make sure that first the downgrade of invenio-accounts is executed | ||
# Since this depends on that revision, when downgrading it will execute this one first but this is wrong | ||
# because in order to alter any foreign_key we first need to modify the primary key used (role_id) | ||
accounts_downgrade() | ||
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", | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,21 @@ | |
# Copyright (C) 2022 CERN | ||
# This file is distributed under the same license as the invenio-access | ||
# project. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: invenio-access 1.4.4\n" | ||
"Project-Id-Version: invenio-access 1.4.5\n" | ||
"Report-Msgid-Bugs-To: [email protected]\n" | ||
"POT-Creation-Date: 2022-10-12 09:03+0000\n" | ||
"POT-Creation-Date: 2023-04-28 15:49+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: Babel 2.10.3\n" | ||
"Generated-By: Babel 2.12.1\n" | ||
|
||
#: invenio_access/admin.py:39 | ||
msgid "Email" | ||
|
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