feat(user): add plan_id column for agent quota tier management
This commit is contained in:
parent
083e0df732
commit
f3f5d0b6de
|
|
@ -82,6 +82,11 @@ async def lifespan(_app: FastAPI):
|
||||||
"ALTER TABLE users ADD COLUMN subscription_status VARCHAR(20)",
|
"ALTER TABLE users ADD COLUMN subscription_status VARCHAR(20)",
|
||||||
"ALTER TABLE users ADD COLUMN subscription_period_end DATETIME",
|
"ALTER TABLE users ADD COLUMN subscription_period_end DATETIME",
|
||||||
"ALTER TABLE users ADD COLUMN odoo_partner_id INTEGER",
|
"ALTER TABLE users ADD COLUMN odoo_partner_id INTEGER",
|
||||||
|
# Agent quota tier — defaults to 'free' so existing rows that
|
||||||
|
# predate the quota system land in the free bucket. Admins +
|
||||||
|
# paid subs get bumped to 'pro' / 'pro_max' via the
|
||||||
|
# velxio_subscription Odoo webhook.
|
||||||
|
"ALTER TABLE users ADD COLUMN plan_id VARCHAR(20) NOT NULL DEFAULT 'free'",
|
||||||
]
|
]
|
||||||
for stmt in legacy_migrations:
|
for stmt in legacy_migrations:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -38,5 +38,11 @@ class User(Base):
|
||||||
subscription_status: Mapped[str | None] = mapped_column(String(20), nullable=True)
|
subscription_status: Mapped[str | None] = mapped_column(String(20), nullable=True)
|
||||||
subscription_period_end: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
subscription_period_end: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||||
odoo_partner_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
odoo_partner_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
||||||
|
# Agent quota tier — drives /api/pro/agent/llm rate-limiting via the
|
||||||
|
# PLANS dict in pro/services/quota.py. Defaults to 'free' so anyone
|
||||||
|
# who registers can start using the chat panel right away (subject to
|
||||||
|
# the free-tier daily cap). Bumped to 'pro' / 'pro_max' on successful
|
||||||
|
# PayPal subscription via the velxio_subscription Odoo webhook.
|
||||||
|
plan_id: Mapped[str] = mapped_column(String(20), default="free", nullable=False, index=True)
|
||||||
|
|
||||||
projects: Mapped[list["Project"]] = relationship("Project", back_populates="owner", lazy="select") # noqa: F821
|
projects: Mapped[list["Project"]] = relationship("Project", back_populates="owner", lazy="select") # noqa: F821
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue