-- =============================================================================
-- MICHANGARRITO - 01 SCHEMAS
-- =============================================================================
-- Creación de schemas del sistema
-- =============================================================================

-- Schema de autenticación
CREATE SCHEMA IF NOT EXISTS auth;
COMMENT ON SCHEMA auth IS 'Autenticación y usuarios';

-- Schema de catálogo
CREATE SCHEMA IF NOT EXISTS catalog;
COMMENT ON SCHEMA catalog IS 'Productos y categorías';

-- Schema de ventas
CREATE SCHEMA IF NOT EXISTS sales;
COMMENT ON SCHEMA sales IS 'Ventas, pagos y cortes';

-- Schema de inventario
CREATE SCHEMA IF NOT EXISTS inventory;
COMMENT ON SCHEMA inventory IS 'Stock y movimientos';

-- Schema de clientes
CREATE SCHEMA IF NOT EXISTS customers;
COMMENT ON SCHEMA customers IS 'Clientes y fiados';

-- Schema de pedidos
CREATE SCHEMA IF NOT EXISTS orders;
COMMENT ON SCHEMA orders IS 'Pedidos y entregas';

-- Schema de suscripciones
CREATE SCHEMA IF NOT EXISTS subscriptions;
COMMENT ON SCHEMA subscriptions IS 'Planes y tokens IA';

-- Schema de mensajería
CREATE SCHEMA IF NOT EXISTS messaging;
COMMENT ON SCHEMA messaging IS 'WhatsApp y notificaciones';

-- Permisos
GRANT USAGE ON SCHEMA auth TO michangarrito_dev;
GRANT USAGE ON SCHEMA catalog TO michangarrito_dev;
GRANT USAGE ON SCHEMA sales TO michangarrito_dev;
GRANT USAGE ON SCHEMA inventory TO michangarrito_dev;
GRANT USAGE ON SCHEMA customers TO michangarrito_dev;
GRANT USAGE ON SCHEMA orders TO michangarrito_dev;
GRANT USAGE ON SCHEMA subscriptions TO michangarrito_dev;
GRANT USAGE ON SCHEMA messaging TO michangarrito_dev;

-- Permisos en public
GRANT ALL ON SCHEMA public TO michangarrito_dev;
