summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--perl/Wallet/Admin.pm15
-rwxr-xr-xserver/wallet-admin25
2 files changed, 15 insertions, 25 deletions
diff --git a/perl/Wallet/Admin.pm b/perl/Wallet/Admin.pm
index 511916d..d2e8cb0 100644
--- a/perl/Wallet/Admin.pm
+++ b/perl/Wallet/Admin.pm
@@ -1,7 +1,7 @@
# Wallet::Admin -- Wallet system administrative interface.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2008, 2009, 2010, 2011, 2012
+# Copyright 2008, 2009, 2010, 2011, 2012, 2013
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -24,6 +24,12 @@ use Wallet::Schema;
# that it will sort properly.
$VERSION = '0.07';
+# The last non-DBIx::Class version of Wallet::Schema. If a database has no
+# DBIx::Class versioning, we artificially install this version number before
+# starting the upgrade process so that the automated DBIx::Class upgrade will
+# work properly.
+our $BASE_VERSION = '0.07';
+
##############################################################################
# Constructor, destructor, and accessors
##############################################################################
@@ -166,6 +172,13 @@ sub backup {
sub upgrade {
my ($self) = @_;
+ # Check to see if the database is versioned. If not, install the
+ # versioning table and default version.
+ if (!$self->{dbh}->get_db_version) {
+ $self->{dbh}->install ($BASE_VERSION);
+ }
+
+ # Perform the actual upgrade.
if ($self->{dbh}->get_db_version) {
eval { $self->{dbh}->upgrade; };
}
diff --git a/server/wallet-admin b/server/wallet-admin
index 7e5a402..516423b 100755
--- a/server/wallet-admin
+++ b/server/wallet-admin
@@ -3,7 +3,7 @@
# wallet-admin -- Wallet server administrative commands.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2008, 2009, 2010, 2011
+# Copyright 2008, 2009, 2010, 2011, 2013
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -15,13 +15,6 @@
use strict;
use Wallet::Admin;
-# The last non-DBIx::Class version. If a database has no DBIx::Class
-# versioning, we want to set it to this so that upgrades can begin.
-our $BASE_VERSION = '0.07';
-
-# Directory that contains the wallet SQL files for upgrades.
-our $SQL_DIR = '/usr/share/wallet/sql/';
-
##############################################################################
# Implementation
##############################################################################
@@ -48,9 +41,6 @@ sub command {
die "too few arguments to initialize\n" if @args < 1;
die "invalid admin principal $args[0]\n"
unless $args[0] =~ /^[^\@\s]+\@\S+$/;
-
- my $schema = $admin->{dbh};
- $schema->upgrade_directory ($SQL_DIR);
$admin->initialize (@args) or die $admin->error, "\n";
} elsif ($command eq 'register') {
die "too many arguments to register\n" if @args > 3;
@@ -69,20 +59,7 @@ sub command {
}
} elsif ($command eq 'upgrade') {
die "too many arguments to upgrade\n" if @args;
-
- my $schema = $admin->{dbh};
- $schema->upgrade_directory ($SQL_DIR);
-
- # Check to see if the database is versioned. If not, install the
- # versioning table and default version.
- if (!$schema->get_db_version) {
- print "Versioning database.\n";
- $schema->install ($BASE_VERSION);
- }
-
- # Actually upgrade.
$admin->upgrade or die $admin->error, "\n";
-
} else {
die "unknown command $command\n";
}