Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

1.2 KB
Raw Blame
"""add_owner_id_to_flows

Revision ID: c7d1f0a92b3e
Revises: f4d42260273d
Create Date: 2026-08-23 00:00:00.000000

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "c7d1f0a92b3e"
down_revision: Union[str, None] = "f4d42260273d"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("flows", sa.Column("owner_id", sa.Uuid(), nullable=True))
    op.create_foreign_key(
        "flows_owner_id_fkey",
        "flows",
        "profiles",
        ["owner_id"],
        ["id"],
        onupdate="CASCADE",
        ondelete="SET NULL",
    )
    # Pre-existing flows are left with owner_id=NULL: treated as legacy/shared
    # (readable by everyone, editable/deletable by nobody via the API).
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("flows_owner_id_fkey", "flows", type_="foreignkey")
    op.drop_column("flows", "owner_id")
    # ### end Alembic commands ###