Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/db/core/addHelpersCore.sql
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ ALTER FUNCTION ClassDB.getSchemaOwnerName(ClassDB.IDNameDomain) OWNER TO ClassDB

--Define a function to test if a role name is a ClassDB role name
-- tests if the name supplied is one of the following strings:
-- 'classdb_student', 'classdb_instructor', 'classdb_manager'
-- 'classdb_student', 'classdb_instructor', 'classdb_manager', 'classdb_team'
CREATE OR REPLACE FUNCTION
ClassDB.isClassDBRoleName(roleName ClassDB.IDNameDomain)
RETURNS BOOLEAN AS
$$
SELECT ClassDB.foldPgID($1)
IN ('classdb_instructor', 'classdb_student', 'classdb_dbmanager');
IN ('classdb_instructor', 'classdb_student',
'classdb_dbmanager', 'classdb_team');
$$ LANGUAGE sql
IMMUTABLE
RETURNS NULL ON NULL INPUT;
Expand Down Expand Up @@ -212,8 +213,7 @@ $$
SELECT * FROM pg_catalog.pg_roles
WHERE pg_catalog.pg_has_role(ClassDB.foldPgID($1), oid, 'member')
AND
rolname IN
('classdb_instructor', 'classdb_student', 'classdb_dbmanager')
ClassDB.isClassDBRoleName(rolname::ClassDB.IDNameDomain)
);
$$ LANGUAGE sql
STABLE
Expand Down
7 changes: 5 additions & 2 deletions src/db/core/initializeDBCore.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

START TRANSACTION;

--Suppress NOTICE messages for this script: won't apply to functions created here
-- hides unimportant but possibly confusing msgs generated as the script executes
SET LOCAL client_min_messages TO WARNING;

--Make sure the current user has sufficient privilege to run this script
-- privilege required: superuser
Expand All @@ -50,11 +53,11 @@ BEGIN
SELECT COUNT(*)
FROM pg_catalog.pg_roles
WHERE rolname IN ('classdb', 'classdb_instructor',
'classdb_dbmanager', 'classdb_student'
'classdb_dbmanager', 'classdb_student', 'classdb_team'
)
INTO classDBRoleCount;

IF classDBRoleCount <> 4 THEN
IF classDBRoleCount <> 5 THEN
RAISE EXCEPTION
'Missing roles: one or more expected of the expected ClassDB roles '
'are undefined';
Expand Down
4 changes: 3 additions & 1 deletion src/server/core/initalizeServerCore.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ BEGIN
PERFORM pg_temp.createGroupRole('classdb_student');
PERFORM pg_temp.createGroupRole('classdb_instructor');
PERFORM pg_temp.createGroupRole('classdb_dbmanager');
PERFORM pg_temp.createGroupRole('classdb_team');

GRANT ClassDB_Student, ClassDB_Instructor, ClassDB_DBManager TO ClassDB;
GRANT ClassDB_Student, ClassDB_Instructor, ClassDB_DBManager, ClassDB_Team
TO ClassDB;
END
$$;

Expand Down
1 change: 1 addition & 0 deletions src/server/removeAllFromServer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ SET LOCAL client_min_messages TO WARNING;
DROP ROLE IF EXISTS ClassDB_Instructor;
DROP ROLE IF EXISTS ClassDB_DBManager;
DROP ROLE IF EXISTS ClassDB_Student;
DROP ROLE IF EXISTS ClassDB_Team;
DROP ROLE IF EXISTS ClassDB;

RESET client_min_messages;
Expand Down