# /opt/docker/dev/service_finder/backend/app/models/reference_data.py
from sqlalchemy import Column, Integer, String, DateTime, func
from sqlalchemy.dialects.postgresql import JSONB
from app.database import Base

class ReferenceLookup(Base):
    __tablename__ = "reference_lookup"
    __table_args__ = {"schema": "vehicle"}

    id = Column(Integer, primary_key=True, index=True)
    make = Column(String, nullable=False, index=True)
    model = Column(String, nullable=False, index=True)
    year = Column(Integer, nullable=True, index=True)
    
    # Itt tároljuk az egységesített adatokat
    specs = Column(JSONB, nullable=False)
    
    source = Column(String, nullable=False) # pl: 'os-vehicle-db', 'wikidata'
    source_id = Column(String, nullable=True)
    updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())