from sinapsis_chat_history.providers.postgres import PostgresDatabaseConfig, PostgresStorageProvider


class SupabaseDatabaseConfig(PostgresDatabaseConfig):
    """Connection settings for Supabase PostgreSQL chat history storage."""

    db_name: str = "postgres"
    sslmode: str | None = "require"


class SupabaseStorageProvider(PostgresStorageProvider):
    """Supabase-backed chat history provider using the PostgreSQL wire protocol."""

    config: SupabaseDatabaseConfig

    def initialize(self) -> None:
        """Create the chat history table in an existing Supabase database."""
        self._ensure_dependency()
        self._create_table()
