23 lines
992 B
Python
23 lines
992 B
Python
from sqlalchemy import Boolean, Column, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class Warehouse(Base):
|
|
__tablename__ = "warehouses"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, index=True, nullable=False)
|
|
code = Column(String, unique=True, index=True, nullable=False)
|
|
address = Column(Text, nullable=False)
|
|
city = Column(String, nullable=False)
|
|
state = Column(String, nullable=False)
|
|
country = Column(String, nullable=False)
|
|
postal_code = Column(String, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
# Relationships
|
|
inventory = relationship("Inventory", back_populates="warehouse")
|
|
shipments_from = relationship("Shipment", foreign_keys="Shipment.origin_warehouse_id", back_populates="origin_warehouse")
|
|
shipments_to = relationship("Shipment", foreign_keys="Shipment.destination_warehouse_id", back_populates="destination_warehouse") |