1
0
Fork 0
forked from sr2/cloud-api
cloud-api/src/contact/models.py

35 lines
1 KiB
Python
Raw Normal View History

2026-04-06 12:41:49 +01:00
"""
2026-05-28 11:22:12 +01:00
Database models for the contact module
2026-04-06 12:41:49 +01:00
Models:
- Contact: id[pk], email, first_name, last_name, phonenumber, vat_number
2026-05-28 11:22:12 +01:00
street_address, street_address_line_2, post_office_box_number, address_locality, country_code, address_region, postal_code
2026-04-06 12:41:49 +01:00
"""
2026-06-20 18:42:36 +01:00
from sqlalchemy import ForeignKey
from sqlalchemy.orm import mapped_column, Mapped
2026-06-20 18:42:36 +01:00
from src.models import CustomBase
2026-04-06 12:41:49 +01:00
2026-06-20 18:42:36 +01:00
class Contact(CustomBase):
2026-04-06 12:41:49 +01:00
__tablename__ = "contact"
2026-06-20 18:42:36 +01:00
id: Mapped[int] = mapped_column(primary_key=True)
email: Mapped[str]
first_name: Mapped[str]
last_name: Mapped[str]
phonenumber: Mapped[str]
vat_number: Mapped[str | None] = mapped_column(default=None)
street_address : Mapped[str]
street_address_line_2 : Mapped[str]
post_office_box_number: Mapped[str | None] = mapped_column(default=None)
locality : Mapped[str] # Ie City
country_code : Mapped[str] # Eg GB
address_region: Mapped[str | None] = mapped_column(default=None)
postal_code : Mapped[str]
org_id: Mapped[int] = mapped_column(
ForeignKey("organisation.id", ondelete="CASCADE"), nullable=False
)