QueuePlanUpdateInterval => 300, # seconds
Repos => "$ENV{'HOME'}/repos",
BisectionRevisonGraphSize => '600x300',
+ ExecutiveDbOwningRoleRegexp => 'osstest',
);
augmentconfigdefaults(
PostgreSQL dbname string for the database <DB>. Default is to use
ExecutiveDbnamePat.
+ExecutiveDbOwningRoleRegexp
+ Regexp which is supposed to match the database user used for schema
+ changes - because, that role will end up owning the database objects.
+ Defaults to `osstest'.
+
Adhoc/Custom Flights
====================
# do CREATE DATABASE.)
#
# When setting up a production database, mg-schema-create should
-# be run *AS THE ROLE USER* who is to own all the resources.
+# be run as the role user who is to own all the resources.
#
# Options:
#
. ./cri-getconfig
+./mg-schema-update $quietopt check-user
+
$progress "Populating database..."
$(get_psql_cmd) $quietopt -f schema/initial.sql
QueueDaemonHost $ctrlhost
OwnerDaemonPort ${ctrlports%,*}
QueueDaemonPort ${ctrlports#*,}
+ExecutiveDbOwningRoleRegexp .*
END
mv -f $tcfg.tmp $tcfg
# ./mg-schema-update [<options>] apply [<updatename>...]
# ./mg-schema-update [<options>] show
# ./mg-schema-update [<options>] apply-all
+# ./mg-schema-update [<options>] check-user
#
# Usual rune for applying updates:
#
@state = sort { $a->{Sortkey} <=> $b->{Sortkey} } values %state;
}
+sub check_user () {
+ my $user = $dbh_tests->{pg_user};
+ my $re = $c{ExecutiveDbOwningRoleRegexp};
+ return if $user =~ m/^$re$/o;
+ die "running as wrong user \`$user', expected to match \`$re'\n";
+}
+
sub cmd_list_applied () {
die if @ARGV;
getstate();
die "Will not apply $v->{Name}.sql: $v->{Msg}\n"
unless want_apply($v);
+ check_user();
+
my $fn = $v->{File};
db_retry($dbh_tests, \@all_lock_tables, sub {
print "Appropriate updates applied.\n" unless $quiet;
}
+sub cmd_check_user () {
+ die "too many arguments\n" if @ARGV>1;
+ $c{ExecutiveDbOwningRoleRegexp} = shift @ARGV if @ARGV;
+ check_user();
+}
+
GetOptions('f|force+' => \$force,
'q+' => \$quiet,
'o|oldest=s' => \$there);