from datetime import datetime, timezone
from sqlalchemy import Column, DateTime, String, Text
from sqlalchemy.dialects.postgresql import JSONB
from database.postgres import Base


def _now():
    return datetime.now(timezone.utc)


class ConsoleSetting(Base):
    """Key/value store for console configuration (replaces Firestore 'settings' doc)."""
    __tablename__ = "console_settings"

    key        = Column(String(128), primary_key=True)
    value      = Column(JSONB)                           # any JSON value
    updated_at = Column(DateTime(timezone=True), nullable=False, default=_now, onupdate=_now)


class PublicFeature(Base):
    """Public-facing feature flags and configuration (replaces Firestore 'public_features' doc)."""
    __tablename__ = "public_features"

    key        = Column(String(128), primary_key=True)
    value      = Column(JSONB)
    updated_at = Column(DateTime(timezone=True), nullable=False, default=_now, onupdate=_now)
