videogen/migrations/versions/20260818_1221_d55d6c63d921_gateway_provisioning_keys_usage.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

67 lines
3.3 KiB
Python

"""gateway: provisioning keys + usage
Revision ID: d55d6c63d921
Revises: f4fc322155e3
Create Date: 2026-08-18 12:21:19.330901+00:00
"""
from __future__ import annotations
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'd55d6c63d921'
down_revision: Union[str, None] = 'f4fc322155e3'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('provisioning_keys',
sa.Column('id', sa.String(length=32), nullable=False),
sa.Column('owner_id', sa.String(length=32), nullable=False),
sa.Column('key_hash', sa.String(length=64), nullable=False),
sa.Column('label', sa.String(length=120), server_default=sa.text("('')"), nullable=False),
sa.Column('daily_cap_micros', sa.Integer(), server_default=sa.text('0'), nullable=False),
sa.Column('markup_bps', sa.Integer(), server_default=sa.text('0'), nullable=False),
sa.Column('min_fee_micros', sa.Integer(), server_default=sa.text('0'), nullable=False),
sa.Column('disabled', sa.String(length=1), server_default=sa.text("'0'"), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_provisioning_keys_created_at'), 'provisioning_keys', ['created_at'], unique=False)
op.create_index(op.f('ix_provisioning_keys_key_hash'), 'provisioning_keys', ['key_hash'], unique=True)
op.create_index(op.f('ix_provisioning_keys_owner_id'), 'provisioning_keys', ['owner_id'], unique=False)
op.create_table('gateway_usage',
sa.Column('id', sa.String(length=32), nullable=False),
sa.Column('key_id', sa.String(length=32), nullable=False),
sa.Column('charge_micros', sa.Integer(), nullable=False),
sa.Column('base_cost_micros', sa.Integer(), server_default=sa.text('0'), nullable=False),
sa.Column('model_key', sa.String(length=80), server_default=sa.text("('')"), nullable=False),
sa.Column('correlation_id', sa.String(length=64), server_default=sa.text("('')"), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
sa.ForeignKeyConstraint(['key_id'], ['provisioning_keys.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_gateway_usage_created_at'), 'gateway_usage', ['created_at'], unique=False)
op.create_index(op.f('ix_gateway_usage_key_id'), 'gateway_usage', ['key_id'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_gateway_usage_key_id'), table_name='gateway_usage')
op.drop_index(op.f('ix_gateway_usage_created_at'), table_name='gateway_usage')
op.drop_table('gateway_usage')
op.drop_index(op.f('ix_provisioning_keys_owner_id'), table_name='provisioning_keys')
op.drop_index(op.f('ix_provisioning_keys_key_hash'), table_name='provisioning_keys')
op.drop_index(op.f('ix_provisioning_keys_created_at'), table_name='provisioning_keys')
op.drop_table('provisioning_keys')
# ### end Alembic commands ###