diff options
author | Russ Allbery <rra@stanford.edu> | 2013-03-27 15:19:54 -0700 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2013-03-27 15:19:54 -0700 |
commit | 5df16adc5024c56e3d733741919954308b4d498a (patch) | |
tree | 5f042adaaa988478ca271f41f9b272ef5a1b45b5 /perl/create-ddl | |
parent | 431c3b56a52b9fe3135ab4339bada13ed49bda92 (diff) | |
parent | 6871bae8e26beadaff5035de56b4f70a78961dc9 (diff) |
Merge tag 'upstream/1.0' into debian
Upstream version 1.0
Diffstat (limited to 'perl/create-ddl')
-rwxr-xr-x | perl/create-ddl | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/perl/create-ddl b/perl/create-ddl new file mode 100755 index 0000000..09225fa --- /dev/null +++ b/perl/create-ddl @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w +# +# create-ddl - Create DDL files for Wallet +# +# Written by Jon Robertson <jonrober@stanford.edu> +# Copyright 2012 +# The Board of Trustees of the Leland Stanford Junior University +# +# See LICENSE for licensing terms. + +############################################################################# +# 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 + +B<create-ddl> [B<--help>] [B<--oldversion>=I<version>] + +=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 + +=over 4 + +=item B<--help> + +Prints the perldoc information (this document) for the script. + +=item B<--oldversion>=I<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. + +=back + +=head1 AUTHORS + +Jon Robertson <jonrober@stanford.edu> + +=cut |