from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, DateTime
from app.core.database import Base


class DataLineage(Base):
    __tablename__ = "data_lineage"

    id = Column(Integer, primary_key=True, index=True)
    source_table = Column(String(200), nullable=False)
    source_column = Column(String(200), nullable=True)
    target_table = Column(String(200), nullable=False)
    target_column = Column(String(200), nullable=True)
    relation_type = Column(String(20), default="direct")  # direct, derived, lookup
    script_content = Column(Text)
    created_at = Column(DateTime, default=datetime.utcnow)
