Production
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""Company-owned product master used by every report that references a product."""
|
||||
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import Boolean, ForeignKey, String, UniqueConstraint
|
||||
from sqlalchemy.dialects.postgresql import UUID as PGUUID
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database.base import Base, TimestampMixin, UUIDMixin
|
||||
|
||||
|
||||
class Product(Base, UUIDMixin, TimestampMixin):
|
||||
__tablename__ = "product"
|
||||
__table_args__ = (UniqueConstraint("company_id", "name", name="uq_product_company_name"),)
|
||||
|
||||
company_id: Mapped[uuid.UUID] = mapped_column(
|
||||
PGUUID(as_uuid=True), ForeignKey("company.id", ondelete="RESTRICT"), nullable=False
|
||||
)
|
||||
name: Mapped[str] = mapped_column(String(200), nullable=False)
|
||||
pack: Mapped[str | None] = mapped_column(String(100))
|
||||
unit: Mapped[str | None] = mapped_column(String(50))
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
Reference in New Issue
Block a user