-- Replace {{DATABASE_NAME}} before execution
-- Requires psql (uses \gexec)
SELECT format('CREATE DATABASE %I', '{{DATABASE_NAME}}')
WHERE NOT EXISTS (
  SELECT 1 FROM pg_database WHERE datname = '{{DATABASE_NAME}}'
)\gexec;