POL-10: Add rules table
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
from app.models.user import User, RefreshToken
|
||||
from app.models.organization import Organization
|
||||
from app.models.championship import Championship
|
||||
from app.models.registration import Registration
|
||||
from app.models.participant import ParticipantList
|
||||
from app.models.notification import NotificationLog
|
||||
from app.models.discipline import Discipline
|
||||
from app.models.style import Style
|
||||
from app.models.fee import Fee
|
||||
from app.models.rule import Rule
|
||||
|
||||
__all__ = [
|
||||
"User",
|
||||
"RefreshToken",
|
||||
"Organization",
|
||||
"Championship",
|
||||
"Registration",
|
||||
"ParticipantList",
|
||||
"NotificationLog",
|
||||
"Discipline",
|
||||
"Style",
|
||||
"Fee",
|
||||
"Rule",
|
||||
]
|
||||
|
||||
22
backend/app/models/rule.py
Normal file
22
backend/app/models/rule.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, String, Text, Uuid, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Rule(Base):
|
||||
__tablename__ = "rules"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(Uuid(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
championship_id: Mapped[uuid.UUID] = mapped_column(Uuid(as_uuid=True), ForeignKey("championships.id", ondelete="CASCADE"), nullable=False)
|
||||
# section: 'general' | 'costume' | 'scoring' | 'penalty'
|
||||
section: Mapped[str] = mapped_column(String(20), nullable=False, default="general")
|
||||
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
value: Mapped[str | None] = mapped_column(Text)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
championship: Mapped["Championship"] = relationship(back_populates="rules") # type: ignore[name-defined]
|
||||
Reference in New Issue
Block a user