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


class WatermarkLog(Base):
    __tablename__ = "watermark_log"

    id = Column(Integer, primary_key=True, index=True)
    user_id = Column(Integer, ForeignKey("sys_user.id"), nullable=False)
    export_type = Column(String(20), default="csv")  # csv, excel, txt
    data_scope = Column(Text)  # JSON: {source_id, table_name, row_count}
    watermark_key = Column(String(64), nullable=False)  # random key for this export
    created_at = Column(DateTime, default=datetime.utcnow)

    user = relationship("User")
