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.
feature(models): add workflow run sharing tables
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 1889863
Showing
3 changed files
with
96 additions
and
19 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
46 changes: 46 additions & 0 deletions
46
reana_db/alembic/versions/20240809_2003_4543cde7c9fb_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,46 @@ | ||
"""Workflow sharing. | ||
Revision ID: 4543cde7c9fb | ||
Revises: eb5309f3d8ee | ||
Create Date: 2023-11-02 20:03:01.234086 | ||
Rebase Date: 2024-08-09 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "4543cde7c9fb" | ||
down_revision = "eb5309f3d8ee" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade to 4543cde7c9fb 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.Text(), nullable=True), | ||
sa.Column("valid_until", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["__reana.user_.id_"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["workflow_id"], | ||
["__reana.workflow.id_"], | ||
), | ||
sa.PrimaryKeyConstraint("workflow_id", "user_id"), | ||
schema="__reana", | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade to 377cfbfccf75 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