3 # hack to update/add read-only permissions for a user on the db
5 # usage: pg-readonly freesideuser readonlyuser
9 use FS::UID qw(adminsuidsetup);
10 use FS::Record qw(dbdef);
12 my $user = shift or die &usage;
13 my $rouser = shift or die &usage;
15 my $dbh = adminsuidsetup $user;
17 foreach my $table ( dbdef->tables ) {
18 $dbh->do("GRANT SELECT ON $table TO $rouser");
20 if ( my $pkey = dbdef->table($table)->primary_key ) {
21 $dbh->do("GRANT SELECT ON ${table}_${pkey}_seq TO $rouser");
42 ObjectCustomFieldValues
50 foreach my $table ( @rt_tables ) {
51 $dbh->do("GRANT SELECT ON $table TO $rouser");
53 $dbh->do("GRANT SELECT ON ${table}_id_seq TO $rouser");