-
Notifications
You must be signed in to change notification settings - Fork 31
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 service tables (#241)
- Loading branch information
Showing
3 changed files
with
128 additions
and
0 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
76 changes: 76 additions & 0 deletions
76
reana_db/alembic/versions/20241119_1051_8da6ccf08af9_add_service_tables.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,76 @@ | ||
"""Service tables. | ||
Revision ID: 8da6ccf08af9 | ||
Revises: 2e82f33ee37d | ||
Create Date: 2024-11-19 10:51:51.199670 | ||
""" | ||
|
||
import sqlalchemy_utils | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "8da6ccf08af9" | ||
down_revision = "2e82f33ee37d" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade to 8da6ccf08af9 revision.""" | ||
op.create_table( | ||
"service", | ||
sa.Column("id_", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), | ||
sa.Column("name", sa.String(length=255), nullable=True), | ||
sa.Column("uri", sa.Text(), nullable=True), | ||
sa.Column( | ||
"status", | ||
sa.Enum( | ||
"created", | ||
"running", | ||
"finished", | ||
"failed", | ||
"deleted", | ||
"stopped", | ||
"queued", | ||
"pending", | ||
name="runstatus", | ||
), | ||
nullable=False, | ||
), | ||
sa.Column("owner_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=True), | ||
sa.Column("type_", sa.Enum("dask", name="servicetype"), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["owner_id"], ["__reana.user_.id_"], name=op.f("fk_service_owner_id_user_") | ||
), | ||
sa.PrimaryKeyConstraint("id_", name=op.f("pk_service")), | ||
sa.UniqueConstraint("name", "uri", name=op.f("uq_service_name")), | ||
schema="__reana", | ||
) | ||
op.create_table( | ||
"workflow_service", | ||
sa.Column("workflow_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=True), | ||
sa.Column("service_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["service_id"], | ||
["__reana.service.id_"], | ||
name=op.f("fk_workflow_service_service_id_service"), | ||
), | ||
sa.ForeignKeyConstraint( | ||
["workflow_id"], | ||
["__reana.workflow.id_"], | ||
name=op.f("fk_workflow_service_workflow_id_workflow"), | ||
), | ||
sa.PrimaryKeyConstraint("service_id", name=op.f("pk_workflow_service")), | ||
schema="__reana", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade to 2e82f33ee37d revision.""" | ||
op.drop_table("workflow_service", schema="__reana") | ||
op.drop_table("service", schema="__reana") | ||
# ### end Alembic commands ### |
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