- 6 tables: structures, ranks, nodes, commissions, bonuses, rank_history - 5 enums: structure_type, node_status, commission_type, commission_status, bonus_type - LTREE extension for hierarchical path queries - 24 RLS policies for multi-tenancy - GIST index for LTREE path column Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
21 lines
841 B
SQL
21 lines
841 B
SQL
-- =============================================
|
|
-- 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;
|