do $$ declare root_role_id uuid; root_user_id uuid; begin select id into root_role_id from roles where slug = 'root'; insert into users (username, password_hash) values ( 'root', 'pbkdf2$sha256$210000$pgadmin-root-seed$2dd2c2adeb3a7f89d8dac01f5f991bdf8d674231ac200f4281552e506452df95' ) on conflict (username) do nothing; select id into root_user_id from users where username = 'root'; insert into user_roles (user_id, role_id) values (root_user_id, root_role_id) on conflict do nothing; insert into role_permissions (role_id, permission_id, scope_type, scope_value) select root_role_id, id, 'global', null from permissions on conflict do nothing; end $$;