Rename group
This commit is contained in:
parent
eafb0f4557
commit
5afdd77dcf
@ -1,11 +1,3 @@
|
||||
CREATE OR REPLACE
|
||||
FUNCTION cartodb.CDB_Group_GroupRole(group_name text)
|
||||
RETURNS TEXT AS $$
|
||||
BEGIN
|
||||
RETURN cartoDB.CDB_Organization_Member_Group_Role_Member_Name() || '_g_' || group_name;
|
||||
END
|
||||
$$ LANGUAGE PLPGSQL;
|
||||
|
||||
CREATE OR REPLACE
|
||||
FUNCTION cartodb.CDB_Group_CreateGroup(group_name text)
|
||||
RETURNS TEXT AS $$
|
||||
@ -29,3 +21,23 @@ BEGIN
|
||||
EXECUTE 'DROP ROLE IF EXISTS "' || cartodb.CDB_Group_GroupRole(group_name) || '"';
|
||||
END
|
||||
$$ LANGUAGE PLPGSQL;
|
||||
|
||||
|
||||
CREATE OR REPLACE
|
||||
FUNCTION cartodb.CDB_Group_RenameGroup(old_group_name text, new_group_name text)
|
||||
RETURNS VOID AS $$
|
||||
BEGIN
|
||||
EXECUTE 'ALTER ROLE "' || cartodb.CDB_Group_GroupRole(old_group_name) || '" RENAME TO "' || cartodb.CDB_Group_GroupRole(new_group_name) || '"';
|
||||
END
|
||||
$$ LANGUAGE PLPGSQL;
|
||||
|
||||
-----------------------
|
||||
-- Private functions
|
||||
-----------------------
|
||||
CREATE OR REPLACE
|
||||
FUNCTION cartodb.CDB_Group_GroupRole(group_name text)
|
||||
RETURNS TEXT AS $$
|
||||
BEGIN
|
||||
RETURN cartoDB.CDB_Organization_Member_Group_Role_Member_Name() || '_g_' || group_name;
|
||||
END
|
||||
$$ LANGUAGE PLPGSQL;
|
||||
|
@ -155,7 +155,8 @@ function setup() {
|
||||
sql cdb_testmember_2 'INSERT INTO bar VALUES (1), (2), (3), (4), (5);'
|
||||
sql cdb_testmember_2 'SELECT * FROM cdb_testmember_2.bar;'
|
||||
|
||||
sql "SELECT cartodb.CDB_Group_CreateGroup('${GROUP_A}')"
|
||||
sql "SELECT cartodb.CDB_Group_CreateGroup('${GROUP_A}_tmp')"
|
||||
sql "SELECT cartodb.CDB_Group_RenameGroup('${GROUP_A}_tmp', '${GROUP_A}')"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user