summaryrefslogtreecommitdiff
path: root/rt/etc/upgrade/4.1.1/acl.Pg
blob: 9e8fc0af089e99636af8689a59d91cb92a19c666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

sub acl {
    my $dbh = shift;

    my @acls;

    my @tables = qw (
        objectscrips_id_seq
        ObjectScrips
    );

    my $db_user = RT->Config->Get('DatabaseUser');

    my $sequence_right
        = ( $dbh->{pg_server_version} >= 80200 )
        ? "USAGE, SELECT, UPDATE"
        : "SELECT, UPDATE";

    foreach my $table (@tables) {
        # Tables are upper-case, sequences are lowercase in @tables
        if ( $table =~ /^[a-z]/ ) {
            push @acls, "GRANT $sequence_right ON $table TO \"$db_user\";"
        }
        else {
            push @acls, "GRANT SELECT, INSERT, UPDATE, DELETE ON $table TO \"$db_user\";"
        }
    }
    return (@acls);
}

1;