forked from reanahub/reana-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(models): add workflow run sharing tables (reanahub#216)
Adds a table and an enum to the database. The `user_workflow` table makes it possible to verify whether a specific workflow has been shared with a user. The `accesstype` enum defines the different access types that can be granted to a user. For now, only `read` access is supported. Closes reanahub#206
- Loading branch information
1 parent
67a7254
commit 365ee81
Showing
3 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
reana_db/alembic/versions/20240314_1312_2e82f33ee37d_workflow_sharing.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,51 @@ | ||
"""Workflow sharing. | ||
Revision ID: 2e82f33ee37d | ||
Revises: eb5309f3d8ee | ||
Create Date: 2024-03-14 13:12:01.029714 | ||
""" | ||
|
||
import sqlalchemy_utils | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "2e82f33ee37d" | ||
down_revision = "eb5309f3d8ee" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade to 2e82f33ee37d revision.""" | ||
op.create_table( | ||
"user_workflow", | ||
sa.Column( | ||
"workflow_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False | ||
), | ||
sa.Column("user_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), | ||
sa.Column("access_type", sa.Enum("read", name="accesstype"), nullable=False), | ||
sa.Column("message", sa.String(length=5000), nullable=True), | ||
sa.Column("valid_until", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["__reana.user_.id_"], | ||
name=op.f("fk_user_workflow_user_id_user_"), | ||
), | ||
sa.ForeignKeyConstraint( | ||
["workflow_id"], | ||
["__reana.workflow.id_"], | ||
name=op.f("fk_user_workflow_workflow_id_workflow"), | ||
), | ||
sa.PrimaryKeyConstraint( | ||
"workflow_id", "user_id", name=op.f("pk_user_workflow") | ||
), | ||
schema="__reana", | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade to eb5309f3d8ee revision.""" | ||
op.drop_table("user_workflow", schema="__reana") | ||
sa.Enum(name="accesstype").drop(op.get_bind()) |
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