- Remove `name` from PersonUpdate schema (always computed, prevents bypass)
- Auto-split legacy `name` into first/last on create when only name provided
- Expand backend search to cover first_name, last_name, nickname, email, company
- Add server_default=text('false') to is_favourite and is_frequent model columns
- Add .catch() to clipboard API call in CopyableField
- Extract duplicate renderHeader into shared function in PeoplePage
- Add Escape key handler to close mobile detail panel overlays
- Extract calculate() out of useTableVisibility effects to single function
- Guard getInitials against empty string input
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
1.8 KiB
Python
33 lines
1.8 KiB
Python
from sqlalchemy import String, Text, Date, Boolean, func, text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship as sa_relationship
|
|
from datetime import datetime, date
|
|
from typing import Optional, List
|
|
from app.database import Base
|
|
|
|
|
|
class Person(Base):
|
|
__tablename__ = "people"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
email: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
phone: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
|
address: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
|
birthday: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
|
relationship: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
notes: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
|
# Extended fields
|
|
first_name: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
last_name: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
nickname: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
is_favourite: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text('false'))
|
|
company: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
job_title: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
mobile: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
|
category: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
assigned_tasks: Mapped[List["ProjectTask"]] = sa_relationship(back_populates="person")
|