from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.sql import func
from app.models import Base
from app.config import TABLE_PREFIX

class SampleRecord(Base):
    __tablename__ = f"{TABLE_PREFIX}Sample_Records"

    id = Column(Integer, primary_key=True, index=True)
    sample_id = Column(String(50), unique=True, index=True, nullable=False)
    order_no = Column(String(50), index=True)
    oppy_no = Column(String(100), index=True) # AU 欄
    cust_id = Column(String(100), index=True) # G 欄
    customer = Column(String(255), nullable=False, index=True)
    customer_normalized = Column(String(255), index=True)
    pn = Column(String(100), nullable=False, index=True)
    qty = Column(Integer, default=0)
    date = Column(String(20))
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())
