-- Run these SQL commands ONE AT A TIME in pgAdmin Query Tool
-- Make sure you're connected as a superuser (usually 'postgres')

-- Command 1: Grant ALL permissions on schema
GRANT ALL ON SCHEMA adm_main TO fumbhkhk_adm2;

-- Command 2: Grant CREATE permission (critical for migrations)
GRANT CREATE ON SCHEMA adm_main TO fumbhkhk_adm2;

-- Command 3: Set default privileges for tables
ALTER DEFAULT PRIVILEGES IN SCHEMA adm_main GRANT ALL ON TABLES TO fumbhkhk_adm2;

-- Command 4: Set default privileges for sequences
ALTER DEFAULT PRIVILEGES IN SCHEMA adm_main GRANT ALL ON SEQUENCES TO fumbhkhk_adm2;



-- Verification query (run this to check permissions)
SELECT 
    grantee, 
    privilege_type 
FROM information_schema.schema_privileges 
WHERE schema_name = 'adm_main' 
AND grantee = 'fumbhkhk_adm2';

