feat: add migration to include 'stage_changed' activity type

This commit is contained in:
Artem Kashaev 2025-11-27 16:07:55 +05:00
parent 8c326501bf
commit 969a1b5905
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
"""Add stage_changed activity type."""
from __future__ import annotations
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "20251127_0002_stage_changed"
down_revision: str | None = "20251122_0001"
branch_labels: tuple[str, ...] | None = None
depends_on: tuple[str, ...] | None = None
def upgrade() -> None:
op.execute("ALTER TYPE activity_type ADD VALUE IF NOT EXISTS 'stage_changed';")
def downgrade() -> None:
op.execute("UPDATE activities SET type = 'status_changed' WHERE type = 'stage_changed';")
op.execute("ALTER TYPE activity_type RENAME TO activity_type_old;")
op.execute(
"CREATE TYPE activity_type AS ENUM ('comment','status_changed','task_created','system');"
)
op.execute(
"ALTER TABLE activities ALTER COLUMN type TYPE activity_type USING type::text::activity_type;"
)
op.execute("DROP TYPE activity_type_old;")