From 86b16066bab70eb9f183176e9739305eb576e962 Mon Sep 17 00:00:00 2001 From: Martin Lettry Date: Sun, 23 Apr 2023 18:59:49 +0200 Subject: [PATCH] wip group membership * closes https://github.com/inveniosoftware/invenio-app-rdm/issues/2186 --- ...b7c937cdd3f_change_fk_groupid_to_string.py | 36 +++++++++++++++++++ invenio_communities/members/records/models.py | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 invenio_communities/alembic/ab7c937cdd3f_change_fk_groupid_to_string.py diff --git a/invenio_communities/alembic/ab7c937cdd3f_change_fk_groupid_to_string.py b/invenio_communities/alembic/ab7c937cdd3f_change_fk_groupid_to_string.py new file mode 100644 index 000000000..c82b85d7f --- /dev/null +++ b/invenio_communities/alembic/ab7c937cdd3f_change_fk_groupid_to_string.py @@ -0,0 +1,36 @@ +# +# 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 GroupId to string""" + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "ab7c937cdd3f" +down_revision = "a3f5a8635cbb" +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 ### + + +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 ### diff --git a/invenio_communities/members/records/models.py b/invenio_communities/members/records/models.py index d264fac1f..031201384 100644 --- a/invenio_communities/members/records/models.py +++ b/invenio_communities/members/records/models.py @@ -60,7 +60,7 @@ def user_id(cls): def group_id(cls): """Foreign key to the related group.""" return db.Column( - db.Integer(), + db.String(80), db.ForeignKey(Role.id, ondelete="RESTRICT"), nullable=True, )