From 1e1d8c214d60f675b96c60e585e40d5dbd67f739 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Fri, 13 Dec 2024 16:31:07 -0800 Subject: [PATCH] make display_name not nullable --- .../revisions/tenant/versions/2024-12-12_2d9e4d392ea4.py | 4 +++- src/dispatch/project/models.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dispatch/database/revisions/tenant/versions/2024-12-12_2d9e4d392ea4.py b/src/dispatch/database/revisions/tenant/versions/2024-12-12_2d9e4d392ea4.py index f54a1fadb877..01c33a2ed21e 100644 --- a/src/dispatch/database/revisions/tenant/versions/2024-12-12_2d9e4d392ea4.py +++ b/src/dispatch/database/revisions/tenant/versions/2024-12-12_2d9e4d392ea4.py @@ -19,7 +19,9 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.add_column("project", sa.Column("display_name", sa.String(), nullable=True)) + op.add_column( + "project", sa.Column("display_name", sa.String(), server_default="", nullable=False) + ) # Copy data from 'name' column to 'display_name' column op.execute("UPDATE project SET display_name = name") diff --git a/src/dispatch/project/models.py b/src/dispatch/project/models.py index b50210e977b4..d7d974d3848a 100644 --- a/src/dispatch/project/models.py +++ b/src/dispatch/project/models.py @@ -40,7 +40,7 @@ class Project(Base): cascade="all, delete-orphan", ) - display_name = Column(String, nullable=True) + display_name = Column(String, nullable=False, server_default="") enabled = Column(Boolean, default=True, server_default="t") allow_self_join = Column(Boolean, default=True, server_default="t") @@ -84,7 +84,7 @@ def slug(self): class ProjectBase(DispatchBase): id: Optional[PrimaryKey] name: NameStr - display_name: Optional[str] = Field(None, nullable=True) + display_name: Optional[str] = Field("", nullable=False) owner_email: Optional[EmailStr] = Field(None, nullable=True) owner_conversation: Optional[str] = Field(None, nullable=True) annual_employee_cost: Optional[int]