videogen/migrations/versions/20260828_0500_a3e7c91fd240_wallet_destination_profiles.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

104 lines
3.5 KiB
Python

"""public workspace, agent, and service wallet destinations
Revision ID: a3e7c91fd240
Revises: f2c8d5e03a71
Create Date: 2026-08-28 05:00:00
"""
from __future__ import annotations
from typing import Union
import sqlalchemy as sa
from alembic import op
revision: str = "a3e7c91fd240"
down_revision: Union[str, None] = "f2c8d5e03a71"
branch_labels: Union[str, tuple[str, ...], None] = None
depends_on: Union[str, tuple[str, ...], None] = None
def upgrade() -> None:
op.create_table(
"wallet_destination_profiles",
sa.Column("id", sa.String(length=32), nullable=False),
sa.Column("kind", sa.String(length=20), nullable=False),
sa.Column("handle", sa.String(length=80), nullable=False),
sa.Column("display_name", sa.String(length=200), nullable=False),
sa.Column("account_id", sa.String(length=32), nullable=False),
sa.Column("owner_user_id", sa.String(length=32), nullable=False),
sa.Column("workspace_id", sa.String(length=32), nullable=True),
sa.Column(
"active", sa.Boolean(), server_default=sa.true(), nullable=False
),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=False,
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=False,
),
sa.CheckConstraint(
"kind IN ('workspace', 'agent', 'service')",
name="ck_wallet_destination_profiles_kind",
),
sa.ForeignKeyConstraint(
["account_id"], ["wallet_accounts.id"], ondelete="RESTRICT"
),
sa.ForeignKeyConstraint(
["owner_user_id"], ["users.id"], ondelete="CASCADE"
),
sa.ForeignKeyConstraint(
["workspace_id"], ["workspaces.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("account_id"),
)
# ``handle`` MUST be globally unique (a typed destination like
# ``agent:caption-bot`` must route to exactly one profile). The ORM model
# declares that via ``mapped_column(unique=True, index=True)`` — a single
# UNIQUE INDEX. The inline ``UniqueConstraint("handle")`` above was redundant
# with this index (double-declaring uniqueness) and surfaced as drift
# (``wallet_destination_profiles_handle_key`` present in DB, absent in the
# model). Uniqueness is preserved by this unique index alone.
op.create_index(
"ix_wallet_destination_profiles_handle",
"wallet_destination_profiles",
["handle"],
unique=True,
)
op.create_index(
"ix_wallet_destination_profiles_owner_user_id",
"wallet_destination_profiles",
["owner_user_id"],
unique=False,
)
op.create_index(
"ix_wallet_destination_profiles_workspace_id",
"wallet_destination_profiles",
["workspace_id"],
unique=False,
)
def downgrade() -> None:
op.drop_index(
"ix_wallet_destination_profiles_workspace_id",
table_name="wallet_destination_profiles",
)
op.drop_index(
"ix_wallet_destination_profiles_owner_user_id",
table_name="wallet_destination_profiles",
)
op.drop_index(
"ix_wallet_destination_profiles_handle",
table_name="wallet_destination_profiles",
)
op.drop_table("wallet_destination_profiles")