Configure roles and permissions suitable for Travis auth feature specs

This commit is contained in:
Joe Nelson
2014-09-30 22:44:02 -07:00
parent 598d70579e
commit 7e9c224299
7 changed files with 381 additions and 112 deletions
+19 -3
View File
@@ -1,3 +1,19 @@
select create_role_if_not_exists('dbapi');
select create_role_if_not_exists('dbapi_anonymous');
select create_role_if_not_exists('test_default_role');
create function pg_temp.create_role_if_not_exists(rolename name, opts character varying) RETURNS text
LANGUAGE plpgsql
AS $$
BEGIN
IF NOT EXISTS (SELECT * FROM pg_roles WHERE rolname = rolename) THEN
EXECUTE format('CREATE ROLE %I %s', rolename, opts);
RETURN 'CREATE ROLE';
ELSE
RETURN format('ROLE ''%I'' ALREADY EXISTS', rolename);
END IF;
END;
$$;
select pg_temp.create_role_if_not_exists('dbapi_anonymous', 'with login');
select pg_temp.create_role_if_not_exists('test_default_role', 'with login');
select pg_temp.create_role_if_not_exists('dbapi_test_author', 'with nologin');
select pg_temp.create_role_if_not_exists('dbapi_test_author_a', 'with login in role dbapi_test_author');
select pg_temp.create_role_if_not_exists('dbapi_test_author_b', 'with login in role dbapi_test_author');