-- ============================================
-- ColaFlow Database Initialization Script
-- This script runs automatically when PostgreSQL container starts for the first time
-- File: /docker-entrypoint-initdb.d/01-init-db.sql
-- ============================================

-- Enable required extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";       -- UUID generation functions
CREATE EXTENSION IF NOT EXISTS "pg_trgm";         -- Full-text search support (trigram matching)
CREATE EXTENSION IF NOT EXISTS "btree_gin";       -- GIN index optimization for multi-column queries

-- Grant all privileges on database
GRANT ALL PRIVILEGES ON DATABASE colaflow TO colaflow;

-- Output confirmation
DO $$
BEGIN
    RAISE NOTICE '========================================';
    RAISE NOTICE 'ColaFlow Database Initialized Successfully!';
    RAISE NOTICE '========================================';
    RAISE NOTICE 'Extensions installed:';
    RAISE NOTICE '  - uuid-ossp (UUID generation)';
    RAISE NOTICE '  - pg_trgm (Full-text search)';
    RAISE NOTICE '  - btree_gin (Index optimization)';
    RAISE NOTICE '';
    RAISE NOTICE 'Next: EF Core migrations will create schema';
    RAISE NOTICE 'Next: Seed data will populate demo accounts';
    RAISE NOTICE '========================================';
END $$;
