+ my @sorted_names;
+ if ($column_order && scalar @{ $column_order }) {
+ @sorted_names = @{ $column_order };
+ } else {
+ @sorted_names = sort keys %column_lengths;
+ }
+
+ my $format = join('|', map { '%-' . $column_lengths{$_} . 's' } @sorted_names) . "\n";
+
+ printf $format, @sorted_names;
+ print join('+', map { '-' x $column_lengths{$_} } @sorted_names) . "\n";
+
+ foreach my $row (@{ $results }) {
+ printf $format, map { $row->{$_} } @sorted_names;
+ }
+ printf "(\%d row\%s)\n", scalar @{ $results }, scalar @{ $results } > 1 ? 's' : '';
+}
+
+sub dump_applied {
+ my @results;
+
+ my $dbh = $opt_auth_db ? connect_auth()->dbconnect : SL::DB->client->dbh;
+ $dbh->{AutoCommit} = 0;
+
+ $dbh->{PrintWarn} = 0;
+ $dbh->{PrintError} = 0;
+
+ $user->create_schema_info_table($form, $dbh);
+
+ my $query = qq|SELECT tag, login, itime FROM schema_info ORDER BY itime|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute() || $form->dberror($query);
+ while (my $ref = $sth->fetchrow_hashref()) {
+ push @results, $ref;
+ }
+ $sth->finish();
+
+ $dbh->disconnect unless $opt_auth_db;
+
+ if (!scalar @results) {
+ print "No database upgrades have been applied yet.\n";
+ } else {
+ dump_sql_result(\@results, [qw(tag login itime)]);
+ }
+}
+
+sub dump_unapplied {
+ my @results;
+
+ my $dbh = $opt_auth_db ? connect_auth()->dbconnect : SL::DB->client->dbh;
+
+ $dbh->{PrintWarn} = 0;
+ $dbh->{PrintError} = 0;
+
+ my @unapplied = $dbupgrader->unapplied_upgrade_scripts($dbh);
+
+ $dbh->disconnect unless $opt_auth_db;
+
+ if (!scalar @unapplied) {
+ print "All database upgrades have been applied.\n";
+ } else {
+ print map { $_->{tag} . "\n" } @unapplied;
+ }