fed8b2eed7
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Backend release / release (push) Has been cancelled
Bandit Security Scan / bandit_scan (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / manifest (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / manifest (push) Has been cancelled
Python linting / ruff (push) Has been cancelled
Run python tests with pytest / Run tests and count coverage (3.12) (push) Has been cancelled
React Widget Build / build (push) Has been cancelled
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""0019 agent slug — stable per-user identifier for YAML export/import.
|
|
|
|
Adds ``agents.slug`` (CITEXT) plus a partial unique index on
|
|
``(user_id, slug)`` where slug is not null, so an exported agent can be
|
|
re-imported idempotently (and mapped from a repo file for GitOps) while
|
|
still allowing multiple agents to carry NULL. Idempotent both ways.
|
|
|
|
Revision ID: 0019_agent_slug
|
|
Revises: 0018_tool_attempts_attribution
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
|
|
|
|
revision: str = "0019_agent_slug"
|
|
down_revision: Union[str, None] = "0018_tool_attempts_attribution"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.execute("ALTER TABLE agents ADD COLUMN IF NOT EXISTS slug CITEXT;")
|
|
op.execute(
|
|
"""
|
|
CREATE UNIQUE INDEX IF NOT EXISTS ix_agents_user_slug
|
|
ON agents (user_id, slug)
|
|
WHERE slug IS NOT NULL;
|
|
"""
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.execute("DROP INDEX IF EXISTS ix_agents_user_slug;")
|
|
op.execute("ALTER TABLE agents DROP COLUMN IF EXISTS slug;")
|