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
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.
84 lines
4.6 KiB
Python
84 lines
4.6 KiB
Python
"""marketplace_templates + template_ratings
|
|
|
|
Revision ID: 43d4be4d7d5e
|
|
Revises: 4e73c6aaa0a5
|
|
Create Date: 2026-08-12 17:00:11.000000+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 = '43d4be4d7d5e'
|
|
down_revision: Union[str, None] = '4e73c6aaa0a5'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Template Marketplace: two brand-new tables. ``marketplace_templates`` holds
|
|
# a creator's PUBLIC, immutable-snapshot job template (prompt / params / tags
|
|
# / language / layout copied at publish time so a later edit to the author's
|
|
# private template never mutates the listing); ``template_ratings`` holds one
|
|
# 1..5 star rating per (template, user) with the denormalized aggregate
|
|
# (rating_avg / rating_count) maintained on the listing. Both are new tables,
|
|
# so the CREATE is safe on an already-populated database and existing rows /
|
|
# prior tests are unaffected. ``author_user_id`` is indexed for owner-scoped
|
|
# listing + owner-scoped edit/unpublish; ``published`` is indexed so the hot
|
|
# browse filter never scans the table. Columns declare their server_default so
|
|
# the row shape is self-describing and Alembic autogenerate reports no drift.
|
|
op.create_table(
|
|
'marketplace_templates',
|
|
sa.Column('id', sa.String(length=32), nullable=False),
|
|
sa.Column('author_user_id', sa.String(length=32), nullable=False),
|
|
sa.Column('title', sa.String(length=300), server_default=sa.text("('')"), nullable=False),
|
|
sa.Column('description', sa.Text(), server_default=sa.text("('')"), nullable=False),
|
|
sa.Column('prompt', sa.Text(), server_default=sa.text("('')"), nullable=False),
|
|
sa.Column('params', sa.JSON(), nullable=False),
|
|
sa.Column('tags', sa.JSON(), nullable=False),
|
|
sa.Column('language', sa.String(length=20), server_default=sa.text("('en')"), nullable=False),
|
|
sa.Column('layout', sa.String(length=40), server_default=sa.text("('')"), nullable=False),
|
|
sa.Column('rating_avg', sa.Float(), server_default=sa.text('0'), nullable=False),
|
|
sa.Column('rating_count', sa.Integer(), server_default=sa.text('0'), nullable=False),
|
|
sa.Column('clone_count', sa.Integer(), server_default=sa.text('0'), nullable=False),
|
|
sa.Column('published', 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.ForeignKeyConstraint(['author_user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
)
|
|
op.create_index(op.f('ix_marketplace_templates_author_user_id'), 'marketplace_templates', ['author_user_id'], unique=False)
|
|
op.create_index(op.f('ix_marketplace_templates_published'), 'marketplace_templates', ['published'], unique=False)
|
|
|
|
op.create_table(
|
|
'template_ratings',
|
|
sa.Column('id', sa.String(length=32), nullable=False),
|
|
sa.Column('template_id', sa.String(length=32), nullable=False),
|
|
sa.Column('user_id', sa.String(length=32), nullable=False),
|
|
sa.Column('stars', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
|
sa.ForeignKeyConstraint(['template_id'], ['marketplace_templates.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('template_id', 'user_id', name='uq_template_ratings_template_user'),
|
|
)
|
|
op.create_index(op.f('ix_template_ratings_template_id'), 'template_ratings', ['template_id'], unique=False)
|
|
op.create_index(op.f('ix_template_ratings_user_id'), 'template_ratings', ['user_id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_template_ratings_user_id'), table_name='template_ratings')
|
|
op.drop_index(op.f('ix_template_ratings_template_id'), table_name='template_ratings')
|
|
op.drop_table('template_ratings')
|
|
op.drop_index(op.f('ix_marketplace_templates_published'), table_name='marketplace_templates')
|
|
op.drop_index(op.f('ix_marketplace_templates_author_user_id'), table_name='marketplace_templates')
|
|
op.drop_table('marketplace_templates')
|
|
# ### end Alembic commands ###
|