Product_Maker_id = Column(Uuid, primary_key=True, server_default=func.uuid_generate_v4())
business_name = Column(Text, nullable=False)
business_registration_path = Column(Text, nullable=False)
year_incorporated = Column(Text, nullable=False)
founder_ceo = Column(Text, nullable=False)
website = Column(Text, nullable=False)
category = Column(Text, nullable=False)
# Office Address composite columns
office_address = composite(Address,
Column('office_street', String(255)),
Column('office_city', String(255)),
Column('office_state', String(255)),
Column('office_postal_code', String(20)),
Column('office_country', String(255)))
# Warehouse Address composite columns
warehouse_address = composite(Address,
Column('warehouse_street', String(255)),
Column('warehouse_city', String(255)),
Column('warehouse_state', String(255)),
Column('warehouse_postal_code', String(20)),
Column('warehouse_country', String(255)))
# Telephone composite columns
telephone = composite(Telephone,
Column('tel_country_code', String(10)),
Column('tel_area_code', String(10)),
Column('tel_number', String(50)))
# For arrays of composite types, we need separate tables with relationships
# These will be handled as separate tables below
validation_status = Column(Boolean, nullable=False)
last_validation_date = Column(Date, nullable=False)
created_at = Column(TIMESTAMP, nullable=False)
created_by = Column(Text, nullable=False)
updated_at = Column(TIMESTAMP, nullable=False)
TSI_User_Info_id = Column(Uuid, ForeignKey('TSI_User_Info.TSI_User_Info_id'))
tsi_user_info = relationship("TSIUserInfo", back_populates="product_makers")
awards = relationship("ProductMakerAward", back_populates="product_maker", cascade="all, delete-orphan")
contact_persons = relationship("ProductMakerContactPerson", back_populates="product_maker", cascade="all, delete-orphan")
programs = relationship("ProductMakerProgram", back_populates="product_maker", cascade="all, delete-orphan")
from datetime import date, datetime
from typing import List, Optional
from sqlalchemy import Boolean, Date, ForeignKey, String, TIMESTAMP, Text, func
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.composite import composite
from sqlalchemy.orm import Mapped, mapped_column, relationship
class ProductMaker(Base):
__tablename__ = 'Product_Maker'
Product_Maker_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
primary_key=True,
server_default=func.uuid_generate_v4()
)
business_name: Mapped[str] = mapped_column(Text, nullable=False)
business_registration_path: Mapped[str] = mapped_column(Text, nullable=False)
year_incorporated: Mapped[str] = mapped_column(Text, nullable=False)
founder_ceo: Mapped[str] = mapped_column(Text, nullable=False)
website: Mapped[str] = mapped_column(Text, nullable=False)
category: Mapped[str] = mapped_column(Text, nullable=False)
# Office Address composite columns
office_address: Mapped[Address] = composite(
Address,
mapped_column('office_street', String(255)),
mapped_column('office_city', String(255)),
mapped_column('office_state', String(255)),
mapped_column('office_postal_code', String(20)),
mapped_column('office_country', String(255))
)
# Warehouse Address composite columns
warehouse_address: Mapped[Address] = composite(
Address,
mapped_column('warehouse_street', String(255)),
mapped_column('warehouse_city', String(255)),
mapped_column('warehouse_state', String(255)),
mapped_column('warehouse_postal_code', String(20)),
mapped_column('warehouse_country', String(255))
)
# Telephone composite columns
telephone: Mapped[Telephone] = composite(
Telephone,
mapped_column('tel_country_code', String(10)),
mapped_column('tel_area_code', String(10)),
mapped_column('tel_number', String(50))
)
validation_status: Mapped[bool] = mapped_column(Boolean, nullable=False)
last_validation_date: Mapped[date] = mapped_column(Date, nullable=False)
created_at: Mapped[datetime] = mapped_column(TIMESTAMP, nullable=False)
created_by: Mapped[str] = mapped_column(Text, nullable=False)
updated_at: Mapped[datetime] = mapped_column(TIMESTAMP, nullable=False)
TSI_User_Info_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey('TSI_User_Info.TSI_User_Info_id')
)
# Relationships with type hints
tsi_user_info: Mapped["TSIUserInfo"] = relationship(
"TSIUserInfo",
back_populates="product_makers"
)
awards: Mapped[List["ProductMakerAward"]] = relationship(
"ProductMakerAward",
back_populates="product_maker",
cascade="all, delete-orphan"
)
contact_persons: Mapped[List["ProductMakerContactPerson"]] = relationship(
"ProductMakerContactPerson",
back_populates="product_maker",
cascade="all, delete-orphan"
)
programs: Mapped[List["ProductMakerProgram"]] = relationship(
"ProductMakerProgram",
back_populates="product_maker",
cascade="all, delete-orphan"
)