aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2025-12-28 20:51:23 +0100
committerDaniel Schadt <kingdread@gmx.de>2025-12-30 19:16:32 +0100
commita6c74f3422a61cdb4814f6daf3b2289a5e8f47aa (patch)
tree72ac0640b8e6dabd47f678098793b2178599fcd6
parentc633d8eaa72acf226bc53fb66914f3672291c7f3 (diff)
downloadfietsboek-a6c74f3422a61cdb4814f6daf3b2289a5e8f47aa.tar.gz
fietsboek-a6c74f3422a61cdb4814f6daf3b2289a5e8f47aa.tar.bz2
fietsboek-a6c74f3422a61cdb4814f6daf3b2289a5e8f47aa.zip
make columns non-NULLABLE
* We don't want orphan journeys, so having owner_id NOT NULL is clear. * We don't want no titles, that's basically the point of journeys. * We could allow NULL for descriptions, but it seems silly -- we can always allow the empty string, and we don't meaningfully distinguish between them in the UI anyway. * We don't want an unspecified visibility, so that's NOT NULL. * We could imagine having a link secret of NULL, to potentially disable link sharing for a journey, so we keep this field nullable.
-rw-r--r--fietsboek/models/journey.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/fietsboek/models/journey.py b/fietsboek/models/journey.py
index 81bf30c..f726efd 100644
--- a/fietsboek/models/journey.py
+++ b/fietsboek/models/journey.py
@@ -69,10 +69,10 @@ journey_track_assoc = Table(
class Journey(Base):
__tablename__ = "journeys"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
- owner_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"))
- title: Mapped[str | None] = mapped_column(Text)
- description: Mapped[str | None] = mapped_column(Text)
- visibility: Mapped[Visibility | None] = mapped_column(Enum(Visibility))
+ owner_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False)
+ title: Mapped[str] = mapped_column(Text, nullable=False)
+ description: Mapped[str] = mapped_column(Text, nullable=False)
+ visibility: Mapped[Visibility] = mapped_column(Enum(Visibility), nullable=False)
link_secret: Mapped[str | None] = mapped_column(Text)
owner: Mapped["models.User"] = relationship("User", back_populates="journeys")