feat: introduced plans pricing

This commit is contained in:
2026-07-25 15:31:44 +07:00
parent 633c79e817
commit 2547bcfcba
10 changed files with 144 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
from .addons import Addon
from .pricing import PricingConfig
from .sessions import Session
from .users import User
__all__ = ["PricingConfig", "Session", "User"]
__all__ = ["Addon", "PricingConfig", "Session", "User"]

13
db/models/addons.py Normal file
View File

@@ -0,0 +1,13 @@
from sqlalchemy import FLOAT, INTEGER, TEXT
from sqlalchemy.orm import Mapped, mapped_column
from db.base import Base
class Addon(Base):
__tablename__ = "addons"
id: Mapped[str] = mapped_column(TEXT, nullable=False, unique=True, primary_key=True)
name: Mapped[str] = mapped_column(TEXT, nullable=False, unique=False)
price: Mapped[float] = mapped_column(FLOAT, nullable=False)
free_threshold: Mapped[int] = mapped_column(INTEGER, default=-1)

View File

@@ -9,11 +9,13 @@ from db.base import Base
class PricingConfig(Base):
__tablename__ = "pricing_configs"
__table_args__ = (
CheckConstraint("id = 1", name="single_row_check"),
)
__table_args__ = (CheckConstraint("id = 1", name="single_row_check"),)
id: Mapped[int] = mapped_column(INTEGER, autoincrement=True, unique=True, nullable=False, primary_key=True)
id: Mapped[int] = mapped_column(
INTEGER, autoincrement=True, unique=True, nullable=False, primary_key=True
)
device_price: Mapped[float] = mapped_column(FLOAT, nullable=False)
updated_at: Mapped[datetime] = mapped_column(TIMESTAMP, server_default=func.now(), onupdate=func.now())
updated_at: Mapped[datetime] = mapped_column(
TIMESTAMP, server_default=func.now(), onupdate=func.now()
)