Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roles refactoring: Add new project_member table, update getter/setter… #319

Open
wants to merge 2 commits into
base: develop-roles-refactor
Choose a base branch
from

Conversation

MarcelGeo
Copy link
Contributor

@MarcelGeo MarcelGeo commented Nov 5, 2024

Copy link
Contributor Author

@MarcelGeo MarcelGeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migration is not running without intarray extension in postgres.
possible alternative would be use EXCEPT operator

SELECT DISTINCT project_id, user_id, role FROM (SELECT
                        project_id AS project_id,
                        unnest(owners) AS user_id,
                        'owner' AS role
                FROM project_access
UNION
SELECT
    project_id,
    unnest(writer_ids) AS user_id,
    'writer' AS role
FROM (
    SELECT
        project_id,
        array(SELECT UNNEST(writers) EXCEPT SELECT UNNEST(owners)) AS writer_ids
    FROM project_access
) AS subquery
UNION
SELECT
    project_id,
    unnest(writer_ids) AS user_id,
    'writer' AS role
FROM (
    SELECT
        project_id,
        array(SELECT UNNEST(editors) EXCEPT SELECT UNNEST(array_cat(writers, owners))) AS writer_ids
    FROM project_access
) AS subquery) unioned
;

Another problem shoukd be with results of query, where multiple non unique users ids is returned.

do we want to use intarray extension?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants