aboutsummaryrefslogtreecommitdiff
path: root/perl/create-ddl
diff options
context:
space:
mode:
authorJon Robertson <jonrober@stanford.edu>2012-12-02 22:07:16 -0800
committerRuss Allbery <rra@stanford.edu>2013-01-30 18:33:23 -0800
commit593e9b1e100ace54d1d9da7eb16e60f4e37c34ff (patch)
tree6d29f76135fff795f6a15f9b379fc6dee72d14f0 /perl/create-ddl
parent6530fb472f1c64d3e80c723d3073ca3d256a58ce (diff)
Moved the Perl wallet modules and tests to DBIx::Class
Moved all the Perl code to use DBIx::Class for the database interface. This includes updating all database calls, how the schema is generated and maintained, and the tests in places where some output has changed. We also remove the schema.t test, as the tests for it are more covered in the admin.t tests now. Change-Id: Ie5083432d09a0d9fe364a61c31378b77aa7b3cb7 Reviewed-on: https://gerrit.stanford.edu/598 Reviewed-by: Russ Allbery <rra@stanford.edu> Tested-by: Russ Allbery <rra@stanford.edu>
Diffstat (limited to 'perl/create-ddl')
-rwxr-xr-xperl/create-ddl93
1 files changed, 93 insertions, 0 deletions
diff --git a/perl/create-ddl b/perl/create-ddl
new file mode 100755
index 0000000..62deb86
--- /dev/null
+++ b/perl/create-ddl
@@ -0,0 +1,93 @@
+#!/usr/bin/perl -w
+#
+# create-ddl - Create DDL files for Wallet
+#
+# Written by Jon Robertson <jonrober@stanford.edu>
+# Copyright 2012 Board of Trustees, Leland Stanford Jr. University
+
+#############################################################################
+# Modules and declarations
+#############################################################################
+
+use strict;
+use vars qw();
+
+use Getopt::Long;
+use Wallet::Admin;
+
+#############################################################################
+# Main routine
+#############################################################################
+
+# Get errors and output in the same order.
+$| = 0;
+
+# Clean up the path name.
+my $fullpath = $0;
+$0 =~ s%^.*/%%;
+
+# Parse command-line options.
+my ($help);
+my $oldversion = '';
+Getopt::Long::config ('bundling');
+GetOptions ('h|help' => \$help,
+ 'o|oldversion=s' => \$oldversion) or exit 1;
+if ($help) {
+ print "Feeding myself to perldoc, please wait....\n";
+ exec ('perldoc', '-t', $fullpath);
+}
+
+# Default wallet settings, for Wallet::Admin.
+$Wallet::Config::DB_DDL_DIRECTORY = 'sql/';
+$Wallet::Config::DB_DRIVER = 'SQLite';
+$Wallet::Config::DB_INFO = 'wallet-db';
+
+# Create a Wallet::Admin object and run the backup.
+my $admin = Wallet::Admin->new;
+$admin->backup ($oldversion);
+
+exit(0);
+
+##############################################################################
+# Documentation
+##############################################################################
+
+=head1 NAME
+
+create-ddl - Create DDL files for Wallet
+
+=head1 SYNOPSIS
+
+create-ddl [B<--help>] [B<--oldversion>]
+
+=head1 DESCRIPTION
+
+create-ddl is used to create DDL files for the various DBIx::Class
+Wallet::Schema modules. It simply is an interface for the backup command
+in Wallet::Admin, which does the work via DBIx::Class. The end result
+is a number of files that can be used to load the database for each
+supported database server.
+
+These files can be modified after creation to customize the database
+load, though should only be done when necessary to prevent confusion
+for the schema modules not matching the actual table definitions. This
+is currently only done in the case of SQLite databases, due to the
+SQLite parser creating keys without AUTOINCREMENT.
+
+=head1 OPTIONS
+
+B<--help>
+
+Prints the perldoc information (this document) for the script.
+
+B<--oldversion>=<version>
+
+The version number of the previous version. If there are existing DDL
+files for this version, then we will also create diff files to upgrade
+a database from the old version to the current.
+
+=head1 AUTHORS
+
+Jon Robertson <jonrober@stanford.edu>
+
+=cut