-- =============================================
-- Schema: mlm
-- Module: SAAS-021 MLM (Multi-Level Marketing)
-- =============================================

-- Crear schema
CREATE SCHEMA IF NOT EXISTS mlm;

-- Comentario
COMMENT ON SCHEMA mlm IS 'MLM multi-level marketing module - network structures, nodes, ranks, and commissions';

-- Grants
GRANT USAGE ON SCHEMA mlm TO template_saas_user;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA mlm TO template_saas_user;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA mlm TO template_saas_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA mlm GRANT ALL PRIVILEGES ON TABLES TO template_saas_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA mlm GRANT ALL PRIVILEGES ON SEQUENCES TO template_saas_user;

-- Enable LTREE extension (required for hierarchical path queries)
CREATE EXTENSION IF NOT EXISTS ltree;
