From a6c74f3422a61cdb4814f6daf3b2289a5e8f47aa Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sun, 28 Dec 2025 20:51:23 +0100 Subject: 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. --- fietsboek/models/journey.py | 8 ++++---- 1 file 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") -- cgit v1.2.3