fix: Fixes pipeline run status migration (#838)

…exist case

<!-- .github/pull_request_template.md -->

## Description
Fixes pipeline run status migration

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.
This commit is contained in:
hajdul88 2025-05-19 13:18:36 +02:00 committed by GitHub
parent 3ed9504375
commit a874988db6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 11 deletions

View file

@ -1,9 +1,8 @@
"""Add pipeline run status
"""Add pipeline run status
Revision ID: 1d0bb7fede17
Revises: 482cd6517ce4
Create Date: 2025-05-19 10:58:15.993314
"""
from typing import Sequence, Union
@ -18,21 +17,16 @@ from cognee.modules.pipelines.models.PipelineRun import PipelineRun, PipelineRun
revision: str = "1d0bb7fede17"
down_revision: Union[str, None] = "482cd6517ce4"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = "482cd6517ce4"
async def upgrade() -> None:
def upgrade() -> None:
db_engine = get_relational_engine()
if db_engine.engine.dialect.name == "postgresql":
op.execute(
f"ALTER TYPE {PipelineRun.status} ADD VALUE IF NOT EXISTS '{str(PipelineRunStatus.DATASET_PROCESSING_INITIATED)}'"
"ALTER TYPE pipelinerunstatus ADD VALUE IF NOT EXISTS 'DATASET_PROCESSING_INITIATED'"
)
else:
op.execute(f"""
ALTER TABLE {PipelineRun}
MODIFY COLUMN {PipelineRun.status} ENUM('{PipelineRunStatus.DATASET_PROCESSING_INITIATED}', '{PipelineRunStatus.DATASET_PROCESSING_STARTED}', '{PipelineRunStatus.DATASET_PROCESSING_COMPLETED}', '{PipelineRunStatus.DATASET_PROCESSING_ERRORED}') NOT NULL
""")
def downgrade() -> None:

View file

@ -21,7 +21,10 @@ depends_on: Union[str, Sequence[str], None] = "8057ae7329c2"
def upgrade() -> None:
await_only(create_default_user())
try:
await_only(create_default_user())
except Exception:
pass
def downgrade() -> None: