Daedalus and Talos integration test
This commit is contained in:
37
backend/src/app/models/journal_entry.py
Normal file
37
backend/src/app/models/journal_entry.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, String, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class JournalEntry(Base):
|
||||
__tablename__ = "journal_entries"
|
||||
|
||||
id: Mapped[UUID] = mapped_column(
|
||||
primary_key=True, server_default=func.gen_random_uuid()
|
||||
)
|
||||
run_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("nuzlocke_runs.id", ondelete="CASCADE"), index=True
|
||||
)
|
||||
boss_result_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("boss_results.id", ondelete="SET NULL"), index=True
|
||||
)
|
||||
title: Mapped[str] = mapped_column(String(200))
|
||||
body: Mapped[str] = mapped_column(Text)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
|
||||
)
|
||||
|
||||
run: Mapped[NuzlockeRun] = relationship(back_populates="journal_entries")
|
||||
boss_result: Mapped[BossResult | None] = relationship()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f"<JournalEntry(id={self.id}, run_id={self.run_id}, title='{self.title}')>"
|
||||
)
|
||||
Reference in New Issue
Block a user