-- setup_db.sql

-- Create user (if it doesn't exist)
DO
$$
BEGIN
   IF NOT EXISTS (
      SELECT FROM pg_catalog.pg_roles WHERE rolname = 'silmataivas'
   ) THEN
      CREATE ROLE silmataivas LOGIN PASSWORD 'silmataivas';
   END IF;
END
$$;

-- Create database owned by the user
CREATE DATABASE silmataivas OWNER silmataivas;

-- Optional: grant all privileges explicitly
GRANT ALL PRIVILEGES ON DATABASE silmataivas TO silmataivas;