from sqlalchemy import Column, Integer, String, Boolean, DateTime
from sqlalchemy.sql import func
from database import Base


class Site(Base):
    __tablename__ = "sites"

    id = Column(Integer, primary_key=True, index=True)
    site_id = Column(String, unique=True, nullable=False, index=True)
    name = Column(String, nullable=False)
    owner_name = Column(String, nullable=False)
    contact_email = Column(String, nullable=False)
    secret_key_hash = Column(String, nullable=False)
    is_active = Column(Boolean, default=True)
    is_locked = Column(Boolean, default=False)
    lock_reason = Column(String, nullable=True)
    license_expires_at = Column(DateTime(timezone=True), nullable=False)
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    last_seen_at = Column(DateTime(timezone=True), nullable=True)
    last_seen_ip = Column(String, nullable=True)
