videogen/migrations/versions/20261009_1500_c3e5a7b9d1f2_content_month.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

82 lines
3.6 KiB
Python

"""Content Month: website -> a month of post ideas (content_plans, content_ideas).
Additive and idempotent (each table is created only when missing).
Revision ID: c3e5a7b9d1f2
Revises: b2d4f6a8c0e1
Create Date: 2026-10-09 15: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 = 'c3e5a7b9d1f2'
down_revision: Union[str, None] = 'b2d4f6a8c0e1'
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 _now() -> sa.sql.elements.ClauseElement:
return sa.func.now()
def upgrade() -> None:
existing = _tables()
if "content_plans" not in existing:
op.create_table(
"content_plans",
sa.Column("id", sa.String(32), primary_key=True),
sa.Column("user_id", sa.String(32), sa.ForeignKey("users.id"), nullable=False),
sa.Column("url", sa.Text(), nullable=False),
sa.Column("name", sa.String(120), nullable=False, server_default=""),
sa.Column("brief_json", sa.JSON(), nullable=False),
sa.Column("style_json", sa.JSON(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=_now()),
)
op.create_index("ix_content_plans_user_id", "content_plans", ["user_id"])
if "content_ideas" not in existing:
op.create_table(
"content_ideas",
sa.Column("id", sa.String(32), primary_key=True),
sa.Column("plan_id", sa.String(32), sa.ForeignKey("content_plans.id", ondelete="CASCADE"),
nullable=False),
sa.Column("user_id", sa.String(32), sa.ForeignKey("users.id"), nullable=False),
sa.Column("position", sa.Integer(), nullable=False, server_default="0"),
sa.Column("format", sa.String(40), nullable=False),
sa.Column("kind", sa.String(16), nullable=False),
sa.Column("hook", sa.Text(), nullable=False, server_default=""),
sa.Column("slides", sa.JSON(), nullable=False),
sa.Column("script", sa.Text(), nullable=False, server_default=""),
sa.Column("caption", sa.Text(), nullable=False, server_default=""),
sa.Column("source", sa.String(16), nullable=False, server_default="rules"),
sa.Column("decision", sa.String(16), nullable=False, server_default="pending"),
sa.Column("decided_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("render_status", sa.String(16), nullable=False, server_default="none"),
sa.Column("outputs", sa.JSON(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=_now()),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False, server_default=_now()),
)
op.create_index("ix_content_ideas_plan_id", "content_ideas", ["plan_id"])
op.create_index("ix_content_ideas_user_id", "content_ideas", ["user_id"])
def downgrade() -> None:
existing = _tables()
if "content_ideas" in existing:
op.drop_index("ix_content_ideas_user_id", table_name="content_ideas")
op.drop_index("ix_content_ideas_plan_id", table_name="content_ideas")
op.drop_table("content_ideas")
if "content_plans" in existing:
op.drop_index("ix_content_plans_user_id", table_name="content_plans")
op.drop_table("content_plans")