57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
"""add api_model_pricings table
|
|
|
|
Revision ID: b2c3d4e5f6g7
|
|
Revises: a1b2c3d4e5f6
|
|
Create Date: 2026-07-28 14:00:00.000000
|
|
|
|
API 模型价格表 - 使用直接金额(元)计费,镜像 credit_ratios 结构。
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'b2c3d4e5f6g7h'
|
|
down_revision: Union[str, None] = 'a1b2c3d4e5f6g'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
'api_model_pricings',
|
|
sa.Column('id', sa.String(32), primary_key=True),
|
|
sa.Column('model_config_id', sa.String(32), nullable=False, index=True),
|
|
sa.Column('gen_type', sa.String(16), nullable=False, default='video', index=True),
|
|
sa.Column('resolution', sa.String(16), nullable=False, index=True),
|
|
sa.Column('price_ratio', sa.Float, nullable=False, default=1.0),
|
|
sa.Column('base_price', sa.Float, nullable=False, default=0.0),
|
|
sa.Column('per_second_price', sa.Float, nullable=False, default=0.0),
|
|
sa.Column('input_video_ratio', sa.Float, nullable=False, default=1.0),
|
|
sa.Column('input_video_base_price', sa.Float, nullable=False, default=0.0),
|
|
sa.Column('input_video_per_second_price', sa.Float, nullable=False, default=0.0),
|
|
sa.Column('input_image_ratio', sa.Float, nullable=False, default=1.0),
|
|
sa.Column('input_image_base_price', sa.Float, nullable=False, default=0.0),
|
|
sa.Column('input_image_per_image_price', sa.Float, nullable=False, default=0.0),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now()),
|
|
)
|
|
op.create_index(
|
|
'ix_api_model_pricings_gen_type_engine_resolution',
|
|
'api_model_pricings',
|
|
['gen_type', 'model_config_id', 'resolution'],
|
|
)
|
|
op.create_index(
|
|
'ix_api_model_pricings_gen_type_resolution',
|
|
'api_model_pricings',
|
|
['gen_type', 'resolution'],
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index('ix_api_model_pricings_gen_type_resolution', table_name='api_model_pricings')
|
|
op.drop_index('ix_api_model_pricings_gen_type_engine_resolution', table_name='api_model_pricings')
|
|
op.drop_table('api_model_pricings')
|