Eli Mesika has uploaded a new change for review. Change subject: core: adding utility for db objects owner change ......................................................................
core: adding utility for db objects owner change This utility change objects in the engine database to be owned by the engine user. Change-Id: I56c59c0fe749389bd110bcd1a39faae74e71174b Signed-off-by: Eli Mesika <emes...@redhat.com> --- A packaging/setup/dbutils/postgres2engineowner.sh 1 file changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/18682/1 diff --git a/packaging/setup/dbutils/postgres2engineowner.sh b/packaging/setup/dbutils/postgres2engineowner.sh new file mode 100755 index 0000000..c776bc9 --- /dev/null +++ b/packaging/setup/dbutils/postgres2engineowner.sh @@ -0,0 +1,26 @@ +################################################################ +# This script change the ownership of objects in the engine +# database to 'engine' +################################################################ +#!/bin/sh + +cmd="select c.relname from pg_class c join pg_roles r on r.oid = c.relowner join pg_namespace n on n.oid = c.relnamespace where c.relkind in ('r','v','S') and n.nspname = 'public' and r.rolname != 'engine';" +res=$(psql -w --pset=tuples_only=on --set ON_ERROR_STOP=1 -c "${cmd}" -U postgres engine) +if [ -n "${res}" ]; then + cmd="" + for tab in $(echo $res); do + cmd=${cmd}"alter table $tab owner to engine; " + done + if [ -n "${cmd}" ]; then + echo "Changing ownership of objects in database engine to owner engine ... " + res=$(psql -w --pset=tuples_only=on --set ON_ERROR_STOP=1 -c "${cmd}" -U postgres engine) + if [ $? -eq 0 ]; then + echo "completed successfully." + else + exit 1 + fi + fi +else + echo "All DB objects have already the engine ownership." +fi + -- To view, visit http://gerrit.ovirt.org/18682 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I56c59c0fe749389bd110bcd1a39faae74e71174b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches