-
Notifications
You must be signed in to change notification settings - Fork 29
♻️ Preparation of tags for both services and projects 🗃️ #6092
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
Merged
pcrespov
merged 28 commits into
ITISFoundation:master
from
pcrespov:is5964/preparation-tags
Aug 27, 2024
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
37fdee6
moves tags_to_groups to separate module
pcrespov 6ed1a86
separate project_tags
pcrespov 505053b
new services tags
pcrespov 8b0d3f4
sql
pcrespov ceeb784
minor
pcrespov b216a1d
renames tags_access_rights
pcrespov 4266f34
rename repo_tags
pcrespov 8e3f4d1
missing import
pcrespov 7597a47
fixes test repo tags
pcrespov 954ad44
rename study_tags
pcrespov 1c86aa7
migration for study_tags
pcrespov 173c537
new services_tags table migration
pcrespov 302e3bc
renames tags_to_groups -> tags_access_rights
pcrespov 420766a
adds migration to change
pcrespov 42a2fb3
doc
pcrespov b901dcc
WIP
pcrespov fe0330f
new bases
pcrespov aaf09b0
new minimal interfaces for repose and context
pcrespov e16ed03
updates tags repo
pcrespov fb29e8a
renames tests
pcrespov fd552ad
drafted repo for asyncio
pcrespov 61eb396
rm new db features
pcrespov 91f472d
adds tests
pcrespov 3a361b7
undo renaming utils_tags
pcrespov 02d8561
cleanup tags/_handlers
pcrespov 0a6daa4
rm sql asyncio
pcrespov f156c37
fixes study_id
pcrespov ac8085f
small renaming
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
...src/simcore_postgres_database/migration/versions/7604e65e2f83_renamed_study_tags_table.py
This file contains hidden or 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,29 @@ | ||
"""renamed study_tags table | ||
|
||
Revision ID: 7604e65e2f83 | ||
Revises: 617e0ecaf602 | ||
Create Date: 2024-08-23 12:03:59.328670+00:00 | ||
|
||
""" | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7604e65e2f83" | ||
down_revision = "617e0ecaf602" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.rename_table("study_tags", "projects_tags") | ||
|
||
# Rename the column from study_id to project_id in the renamed table | ||
op.alter_column("projects_tags", "study_id", new_column_name="project_id") | ||
|
||
|
||
def downgrade(): | ||
# Reverse the column rename from project_id to study_id | ||
op.alter_column("projects_tags", "project_id", new_column_name="study_id") | ||
|
||
# Reverse the table rename from projects_tags to study_tags | ||
op.rename_table("projects_tags", "study_tags") |
44 changes: 44 additions & 0 deletions
44
.../src/simcore_postgres_database/migration/versions/e8057a4a7bb0_new_services_tags_table.py
This file contains hidden or 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,44 @@ | ||
"""new services_tags table | ||
|
||
Revision ID: e8057a4a7bb0 | ||
Revises: 7604e65e2f83 | ||
Create Date: 2024-08-23 12:12:32.883771+00:00 | ||
|
||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "e8057a4a7bb0" | ||
down_revision = "7604e65e2f83" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"services_tags", | ||
sa.Column("service_key", sa.String(), nullable=False), | ||
sa.Column("service_version", sa.String(), nullable=False), | ||
sa.Column("tag_id", sa.BigInteger(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["service_key", "service_version"], | ||
["services_meta_data.key", "services_meta_data.version"], | ||
onupdate="CASCADE", | ||
ondelete="CASCADE", | ||
), | ||
sa.ForeignKeyConstraint( | ||
["tag_id"], ["tags.id"], onupdate="CASCADE", ondelete="CASCADE" | ||
), | ||
sa.UniqueConstraint( | ||
"service_key", "service_version", "tag_id", name="services_tags_uc" | ||
pcrespov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("services_tags") | ||
# ### end Alembic commands ### |
23 changes: 23 additions & 0 deletions
23
...se/src/simcore_postgres_database/migration/versions/feca36c8e18f_rename_tags_to_groups.py
This file contains hidden or 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,23 @@ | ||
"""rename tags_to_groups | ||
|
||
Revision ID: feca36c8e18f | ||
Revises: e8057a4a7bb0 | ||
Create Date: 2024-08-23 12:30:56.650085+00:00 | ||
|
||
""" | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "feca36c8e18f" | ||
down_revision = "e8057a4a7bb0" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.rename_table("tags_to_groups", "tags_access_rights") | ||
pcrespov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def downgrade(): | ||
# Reverse the table rename from projects_tags to study_tags | ||
op.rename_table("tags_access_rights", "tags_to_groups") |
27 changes: 27 additions & 0 deletions
27
packages/postgres-database/src/simcore_postgres_database/models/projects_tags.py
This file contains hidden or 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,27 @@ | ||
import sqlalchemy as sa | ||
|
||
from .base import metadata | ||
from .projects import projects | ||
from .tags import tags | ||
|
||
projects_tags = sa.Table( | ||
# | ||
# Tags associated to a project (many-to-many relation) | ||
# | ||
"projects_tags", | ||
metadata, | ||
sa.Column( | ||
"project_id", | ||
sa.BigInteger, | ||
sa.ForeignKey(projects.c.id, onupdate="CASCADE", ondelete="CASCADE"), | ||
nullable=False, | ||
doc="NOTE that project.c.id != project.c.uuid", | ||
), | ||
sa.Column( | ||
"tag_id", | ||
sa.BigInteger, | ||
sa.ForeignKey(tags.c.id, onupdate="CASCADE", ondelete="CASCADE"), | ||
nullable=False, | ||
), | ||
sa.UniqueConstraint("project_id", "tag_id"), | ||
pcrespov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) |
42 changes: 42 additions & 0 deletions
42
packages/postgres-database/src/simcore_postgres_database/models/services_tags.py
This file contains hidden or 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,42 @@ | ||
import sqlalchemy as sa | ||
|
||
from .base import metadata | ||
from .tags import tags | ||
|
||
services_tags = sa.Table( | ||
# | ||
# Tags assigned to a service (many-to-many relation) | ||
# | ||
"services_tags", | ||
metadata, | ||
# Service | ||
sa.Column( | ||
"service_key", | ||
sa.String, | ||
nullable=False, | ||
doc="Service Key Identifier", | ||
), | ||
sa.Column( | ||
"service_version", | ||
sa.String, | ||
nullable=False, | ||
doc="Service version", | ||
), | ||
# Tag | ||
sa.Column( | ||
"tag_id", | ||
sa.BigInteger, | ||
sa.ForeignKey(tags.c.id, onupdate="CASCADE", ondelete="CASCADE"), | ||
nullable=False, | ||
), | ||
# Constraints | ||
sa.ForeignKeyConstraint( | ||
["service_key", "service_version"], | ||
["services_meta_data.key", "services_meta_data.version"], | ||
onupdate="CASCADE", | ||
ondelete="CASCADE", | ||
), | ||
sa.UniqueConstraint( | ||
"service_key", "service_version", "tag_id", name="services_tags_uc" | ||
), | ||
) | ||
pcrespov marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
66 changes: 66 additions & 0 deletions
66
packages/postgres-database/src/simcore_postgres_database/models/tags_access_rights.py
This file contains hidden or 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,66 @@ | ||
import sqlalchemy as sa | ||
|
||
from ._common import column_created_datetime, column_modified_datetime | ||
from .base import metadata | ||
from .groups import groups | ||
from .tags import tags | ||
|
||
tags_access_rights = sa.Table( | ||
# | ||
# Maps tags with groups to define the level of access rights | ||
# of a group (group_id) for the corresponding tag (tag_id) | ||
# | ||
"tags_access_rights", | ||
metadata, | ||
sa.Column( | ||
"tag_id", | ||
sa.BigInteger(), | ||
sa.ForeignKey( | ||
tags.c.id, | ||
onupdate="CASCADE", | ||
ondelete="CASCADE", | ||
name="fk_tag_to_group_tag_id", | ||
), | ||
nullable=False, | ||
doc="Tag unique ID", | ||
), | ||
sa.Column( | ||
"group_id", | ||
sa.BigInteger, | ||
sa.ForeignKey( | ||
groups.c.gid, | ||
onupdate="CASCADE", | ||
ondelete="CASCADE", | ||
name="fk_tag_to_group_group_id", | ||
), | ||
nullable=False, | ||
doc="Group unique ID", | ||
), | ||
# ACCESS RIGHTS --- | ||
sa.Column( | ||
"read", | ||
sa.Boolean(), | ||
nullable=False, | ||
server_default=sa.sql.expression.true(), | ||
doc="If true, group can *read* a tag." | ||
"This column can be used to set the tag invisible", | ||
), | ||
sa.Column( | ||
"write", | ||
sa.Boolean(), | ||
nullable=False, | ||
server_default=sa.sql.expression.false(), | ||
doc="If true, group can *create* and *update* a tag", | ||
), | ||
sa.Column( | ||
"delete", | ||
sa.Boolean(), | ||
nullable=False, | ||
server_default=sa.sql.expression.false(), | ||
doc="If true, group can *delete* the tag", | ||
), | ||
# TIME STAMPS ---- | ||
column_created_datetime(timezone=False), | ||
column_modified_datetime(timezone=False), | ||
sa.UniqueConstraint("tag_id", "group_id"), | ||
pcrespov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.