25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
from sqlalchemy import Float, Index, String
|
||
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
||
from app.models.base import Base, TimestampMixin
|
||
|
||
|
||
class CreditRatio(Base, TimestampMixin):
|
||
__tablename__ = "credit_ratios"
|
||
__table_args__ = (
|
||
Index("ix_credit_ratios_gen_type_engine_resolution", "gen_type", "model_config_id", "resolution"),
|
||
Index("ix_credit_ratios_gen_type_resolution", "gen_type", "resolution"),
|
||
)
|
||
|
||
id: Mapped[str] = mapped_column(String(32), primary_key=True)
|
||
# 兼容旧字段名:
|
||
# gen_type=image 时,该字段保存 image_engines.id;
|
||
# gen_type=video 时,该字段保存 video_engines.id。
|
||
# 不再通过数据库外键绑定 model_configs.id,避免同一字段无法同时关联图片/视频引擎表。
|
||
model_config_id: Mapped[str] = mapped_column(String(32), index=True)
|
||
gen_type: Mapped[str] = mapped_column(String(16), default="video", index=True)
|
||
resolution: Mapped[str] = mapped_column(String(16), nullable=False, index=True)
|
||
ratio: Mapped[float] = mapped_column(Float, nullable=False)
|
||
base_credits: Mapped[float] = mapped_column(Float, default=80.0)
|
||
per_second_credits: Mapped[float] = mapped_column(Float, default=2.0)
|