videogen/migrations/versions/20261021_1900_b4f6a8c0e2d5_growth_tasks.py
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

68 lines
3.0 KiB
Python

"""Growth Tasks: durable, multi-step agent jobs (competitor research, SEO keyword
discovery, launch-kit bundles) that keep going across sessions, plus a ``body``
column on Brand Agent library items for inline artifact text (briefs, keyword
CSVs, launch bundles) so no new file-storage route is needed.
Additive and idempotent (each table/column is created only when missing).
Revision ID: b4f6a8c0e2d5
Revises: c6e8a0b2d4f6
Create Date: 2026-10-21 19:00:00.000000+00:00
"""
from __future__ import annotations
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = 'b4f6a8c0e2d5'
down_revision: Union[str, None] = 'c6e8a0b2d4f6'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def _tables() -> set[str]:
return set(sa.inspect(op.get_bind()).get_table_names())
def _columns(table: str) -> set[str]:
return {c["name"] for c in sa.inspect(op.get_bind()).get_columns(table)}
def upgrade() -> None:
tables = _tables()
if "agent_library_items" in tables and "body" not in _columns("agent_library_items"):
op.add_column("agent_library_items", sa.Column("body", sa.Text(), nullable=False, server_default=""))
if "agent_growth_tasks" not in tables:
op.create_table(
"agent_growth_tasks",
sa.Column("id", sa.String(32), primary_key=True),
sa.Column("user_id", sa.String(32), sa.ForeignKey("users.id"), nullable=False),
sa.Column("space_id", sa.String(32), sa.ForeignKey("agent_brand_spaces.id"), nullable=False),
sa.Column("session_id", sa.String(32), nullable=True),
sa.Column("kind", sa.String(32), nullable=False),
sa.Column("goal", sa.String(300), nullable=False, server_default=""),
sa.Column("status", sa.String(16), nullable=False, server_default="pending"),
sa.Column("plan", sa.JSON(), nullable=False),
sa.Column("cursor", sa.Integer(), nullable=False, server_default="0"),
sa.Column("result", sa.JSON(), nullable=True),
sa.Column("error", sa.Text(), nullable=False, server_default=""),
sa.Column("lease_until", sa.DateTime(timezone=True), nullable=True),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
)
op.create_index("ix_agent_growth_tasks_user_id", "agent_growth_tasks", ["user_id"])
op.create_index("ix_agent_growth_tasks_space_id", "agent_growth_tasks", ["space_id"])
op.create_index("ix_agent_growth_tasks_status_lease", "agent_growth_tasks", ["status", "lease_until"])
def downgrade() -> None:
tables = _tables()
if "agent_growth_tasks" in tables:
op.drop_table("agent_growth_tasks")
if "agent_library_items" in tables and "body" in _columns("agent_library_items"):
op.drop_column("agent_library_items", "body")