-- Banatie PostgreSQL 15 Permission Fix
-- =====================================
-- This script runs only on first PostgreSQL startup.
-- It grants necessary permissions for the Drizzle ORM to create tables.
--
-- Note: Actual tables are created by Drizzle ORM during deployment:
--   pnpm --filter @banatie/database db:push
--
-- PostgreSQL 15+ removed default CREATE privileges on public schema for security.
-- This script restores those privileges for the service user.

-- Grant CREATE permission on public schema
GRANT CREATE ON SCHEMA public TO banatie_user;
GRANT ALL ON SCHEMA public TO banatie_user;

-- Log completion
DO $$
BEGIN
    RAISE NOTICE 'Banatie database initialized. Run db:push to create tables.';
END $$;
