-- ============================================
-- TEMPLATE-SAAS: Schema Creation
-- Version: 1.0.0
-- ============================================

-- Core schemas
CREATE SCHEMA IF NOT EXISTS auth;
CREATE SCHEMA IF NOT EXISTS tenants;
CREATE SCHEMA IF NOT EXISTS users;
CREATE SCHEMA IF NOT EXISTS billing;
CREATE SCHEMA IF NOT EXISTS plans;

-- Feature schemas
CREATE SCHEMA IF NOT EXISTS audit;
CREATE SCHEMA IF NOT EXISTS notifications;
CREATE SCHEMA IF NOT EXISTS feature_flags;
CREATE SCHEMA IF NOT EXISTS storage;
CREATE SCHEMA IF NOT EXISTS ai;
CREATE SCHEMA IF NOT EXISTS webhooks;

-- Integration schemas
CREATE SCHEMA IF NOT EXISTS whatsapp;

-- Comments
COMMENT ON SCHEMA auth IS 'Authentication: sessions, tokens, OAuth';
COMMENT ON SCHEMA tenants IS 'Multi-tenancy: tenant configuration and settings';
COMMENT ON SCHEMA users IS 'User management: profiles, roles, permissions';
COMMENT ON SCHEMA billing IS 'Billing: subscriptions, invoices, payments';
COMMENT ON SCHEMA plans IS 'Plans: pricing plans, features, limits';
COMMENT ON SCHEMA audit IS 'Audit: activity logs, audit trail';
COMMENT ON SCHEMA notifications IS 'Notifications: templates, queue, delivery logs';
COMMENT ON SCHEMA feature_flags IS 'Feature flags: flags, rollouts, experiments';
COMMENT ON SCHEMA storage IS 'Storage: files, metadata, CDN';
COMMENT ON SCHEMA ai IS 'AI Integration: configurations, usage tracking, rate limits';
COMMENT ON SCHEMA webhooks IS 'Webhooks: outbound webhooks, deliveries, event dispatch';
COMMENT ON SCHEMA whatsapp IS 'WhatsApp: Business API integration, messages, configuration';
