From 48b9023972aa1cb10f6c1eff5eae807274427d03 Mon Sep 17 00:00:00 2001 From: Martin Lettry Date: Wed, 19 Apr 2023 14:06:35 +0200 Subject: [PATCH] wip group membership support * added migration recipe * closes https://github.com/inveniosoftware/invenio-app-rdm/issues/2186 --- ...b56e60_change_fk_accountsrole_to_string.py | 51 +++++++++++++++++++ invenio_access/models.py | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 invenio_access/alembic/842a62b56e60_change_fk_accountsrole_to_string.py diff --git a/invenio_access/alembic/842a62b56e60_change_fk_accountsrole_to_string.py b/invenio_access/alembic/842a62b56e60_change_fk_accountsrole_to_string.py new file mode 100644 index 0000000..ae002d5 --- /dev/null +++ b/invenio_access/alembic/842a62b56e60_change_fk_accountsrole_to_string.py @@ -0,0 +1,51 @@ +# +# 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 + +# revision identifiers, used by Alembic. +revision = "842a62b56e60" +down_revision = "04480be1593e" +branch_labels = () +depends_on = "8f11b75e0995" + + +def upgrade(): + """Upgrade database.""" + # ### commands auto generated by Alembic - please adjust! ### + # op.drop_index("ix_uq_partial_files_object_is_head", table_name="files_object") + # ### end Alembic commands ### + op.alter_column( + "access_actionsroles", + "role_id", + existing_type=sa.Integer, + type_=sa.String(80), + postgresql_using="role_id::integer", + ) + + +def downgrade(): + """Downgrade database.""" + # ### commands auto generated by Alembic - please adjust! ### + # op.create_index( + # "ix_uq_partial_files_object_is_head", + # "files_object", + # ["bucket_id", "key"], + # unique=False, + # ) + # ### end Alembic commands ### + + op.alter_column( + "access_actionsroles", + "role_id", + existing_type=sa.String(80), + type_=sa.Integer, + postgresql_using="role_id::integer", + ) diff --git a/invenio_access/models.py b/invenio_access/models.py index e83af76..b915712 100644 --- a/invenio_access/models.py +++ b/invenio_access/models.py @@ -156,7 +156,7 @@ class ActionRoles(ActionNeedMixin, db.Model): ) role_id = db.Column( - db.Integer(), + db.String(80), db.ForeignKey(Role.id, ondelete="CASCADE"), nullable=False, index=True,