Refactor code structure for improved readability and maintainability
This commit is contained in:
21
app/models/plan.py
Normal file
21
app/models/plan.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlmodel import Field, Relationship
|
||||
|
||||
from app.models.base import BaseModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models.user import User
|
||||
|
||||
|
||||
class Plan(BaseModel, table=True):
|
||||
"""Database model for a plan."""
|
||||
|
||||
code: str = Field(index=True, unique=True, nullable=False)
|
||||
name: str = Field(nullable=False)
|
||||
description: str | None = Field(default=None)
|
||||
credits: int = Field(default=0, ge=0, nullable=False)
|
||||
max_credits: int = Field(default=0, ge=0, nullable=False)
|
||||
|
||||
# relationships
|
||||
users: list["User"] = Relationship(back_populates="plan")
|
||||
Reference in New Issue
Block a user