
sub acl {
    my $dbh = shift;

    my @acls;

    my @tables = qw (
        classes_id_seq
        Classes
        articles_id_seq
        Articles
        topics_id_seq
        Topics
        objecttopics_id_seq
        ObjectTopics
        objectclasses_id_seq
        ObjectClasses
    );

    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
        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;
