00_init.sql (1638B)
1 -- ============================================================ 2 -- INITIALIZATION SCRIPT 3 -- ============================================================ 4 -- Creates database extensions and schemas for microservices 5 6 -- Enable UUID extension globally 7 CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; 8 9 -- ============================================================ 10 -- CREATE SCHEMAS (PostgreSQL namespaces) 11 -- ============================================================ 12 13 -- Products Schema - for Products Service 14 CREATE SCHEMA IF NOT EXISTS products; 15 COMMENT ON SCHEMA products IS 'Products microservice schema - handles catalog, categories, specifications, reviews'; 16 17 -- Inventory Schema - for Inventory Service 18 CREATE SCHEMA IF NOT EXISTS inventory; 19 COMMENT ON SCHEMA inventory IS 'Inventory microservice schema - handles stock management, pricing, discounts'; 20 21 -- Orders Schema - for Orders/Checkout Service 22 CREATE SCHEMA IF NOT EXISTS orders; 23 COMMENT ON SCHEMA orders IS 'Orders microservice schema - handles orders, payments, shipping, checkout'; 24 25 -- Users Schema - for Users/Authentication Service 26 CREATE SCHEMA IF NOT EXISTS users; 27 COMMENT ON SCHEMA users IS 'Users microservice schema - handles user management, authentication, sessions, addresses'; 28 29 -- ============================================================ 30 -- SET DEFAULT SEARCH PATH 31 -- ============================================================ 32 -- This allows cross-schema references to work properly 33 -- Services will override this with their own schema as default 34 35 -- Note: Cannot use CURRENT_DATABASE() in ALTER DATABASE 36 -- Each connection should set search_path as needed