summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
Diffstat (limited to 'perl')
-rw-r--r--perl/Wallet/Schema.pm20
-rwxr-xr-xperl/t/schema.t14
2 files changed, 28 insertions, 6 deletions
diff --git a/perl/Wallet/Schema.pm b/perl/Wallet/Schema.pm
index 25d48cf..07e5ffe 100644
--- a/perl/Wallet/Schema.pm
+++ b/perl/Wallet/Schema.pm
@@ -1,7 +1,8 @@
# Wallet::Schema -- Database schema for the wallet system.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2007, 2008, 2010 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2007, 2008, 2010, 2011
+# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -20,7 +21,7 @@ use DBI;
# This version should be increased on any code change to this module. Always
# use two digits for the minor version with a leading zero if necessary so
# that it will sort properly.
-$VERSION = '0.06';
+$VERSION = '0.07';
##############################################################################
# Data manipulation
@@ -135,7 +136,7 @@ Wallet::Schema - Database schema for the wallet system
=for stopwords
SQL ACL API APIs enums Enums Keytab Backend keytab backend enctypes
-enctype Allbery
+enctype Allbery Metadata metadata
=head1 SYNOPSIS
@@ -190,6 +191,19 @@ empty database.
=head1 SCHEMA
+=head2 Metadata Tables
+
+This table is used to store metadata about the wallet database, used for
+upgrades and in similar situations:
+
+ create table metadata
+ (md_version integer);
+ insert into metadata (md_version) values (1);
+
+This table will normally only have one row. md_version holds the version
+number of the schema (which does not necessarily have any relationship to
+the version number of wallet itself).
+
=head2 Normalization Tables
The following are normalization tables used to constrain the values in
diff --git a/perl/t/schema.t b/perl/t/schema.t
index 40759db..11774d6 100755
--- a/perl/t/schema.t
+++ b/perl/t/schema.t
@@ -3,11 +3,12 @@
# Tests for the wallet schema class.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2007, 2008, 2011
+# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
-use Test::More tests => 8;
+use Test::More tests => 11;
use DBI;
use Wallet::Config;
@@ -21,7 +22,7 @@ ok (defined $schema, 'Wallet::Schema creation');
ok ($schema->isa ('Wallet::Schema'), ' and class verification');
my @sql = $schema->sql;
ok (@sql > 0, 'sql() returns something');
-is (scalar (@sql), 29, ' and returns the right number of statements');
+is (scalar (@sql), 31, ' and returns the right number of statements');
# Connect to a database and test create.
db_setup;
@@ -37,6 +38,13 @@ $dbh->{PrintError} = 0;
eval { $schema->create ($dbh) };
is ($@, '', "create() doesn't die");
+# Check that the version number is correct.
+my $sql = "select md_version from metadata";
+my $version = $dbh->selectall_arrayref ($sql);
+is (@$version, 1, 'metadata has correct number of rows');
+is (@{ $version->[0] }, 1, ' and correct number of columns');
+is ($version->[0][0], 1, ' and the schema version is correct');
+
# Test dropping the database.
eval { $schema->drop ($dbh) };
is ($@, '', "drop() doesn't die");