-
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.
models: add missing foreign key to workflow_uuid of Job
Closes #210
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
reana_db/alembic/versions/20231124_1509_ef26a208a3ae_foreign_key_for_workflow_uuid_of_job.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,50 @@ | ||
"""Foreign key for workflow_uuid of Job. | ||
Revision ID: ef26a208a3ae | ||
Revises: 126601b69c78 | ||
Create Date: 2023-11-24 15:09:49.671968 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "ef26a208a3ae" | ||
down_revision = "126601b69c78" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade to ef26a208a3ae.""" | ||
op.alter_column( | ||
"job", | ||
"workflow_uuid", | ||
existing_type=postgresql.UUID(), | ||
nullable=False, | ||
schema="__reana", | ||
) | ||
op.create_foreign_key( | ||
"_job_workflow_uuid_fk", | ||
"job", | ||
"workflow", | ||
["workflow_uuid"], | ||
["id_"], | ||
source_schema="__reana", | ||
referent_schema="__reana", | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade to 126601b69c78.""" | ||
op.drop_constraint( | ||
"_job_workflow_uuid_fk", "job", schema="__reana", type_="foreignkey" | ||
) | ||
op.alter_column( | ||
"job", | ||
"workflow_uuid", | ||
existing_type=postgresql.UUID(), | ||
nullable=True, | ||
schema="__reana", | ||
) |
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