Bug 6758: DBRev 17.05.00.008
[koha.git] / misc / devel / update_dbix_class_files.pl
bloba291cef48a1e52d7281dbdc012d89a920abb9ce5
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Copyright (C) 2012 ByWater Solutions
6 # Copyright (C) 2013 Equinox Software, Inc.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use Modern::Perl;
23 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
25 use Getopt::Long;
26 use Pod::Usage;
28 my $path = "./";
29 my $db_driver = 'mysql';
30 my $db_host = 'localhost';
31 my $db_port = '3306';
32 my $db_name;
33 my $db_user;
34 my $db_passwd;
35 my $help;
37 GetOptions(
38 "path=s" => \$path,
39 "db_driver=s" => \$db_driver,
40 "db_host=s" => \$db_host,
41 "db_port=s" => \$db_port,
42 "db_name=s" => \$db_name,
43 "db_user=s" => \$db_user,
44 "db_passwd=s" => \$db_passwd,
45 "h|help" => \$help
48 # If we were asked for usage instructions, do it
49 pod2usage(1) if defined $help;
51 if (! defined $db_name ) {
52 print "Error: \'db_name\' parameter is mandatory.\n";
53 pod2usage(1);
54 } else {
56 make_schema_at(
57 "Koha::Schema",
58 { debug => 1, dump_directory => $path, preserve_case => 1 },
59 ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ]
65 =head1 NAME
67 misc/devel/update_dbix_class_files.pl
69 =head1 SYNOPSIS
71 update_dbix_class_files.pl --db_name=db-name --db_user=db-user \
72 --db_passwd=db-pass ...
74 The command in usually called from the root directory for the Koha source tree.
75 If you are running from another directory, use the --path switch to specify
76 a different path.
78 =head1 OPTIONS
80 =over 8
82 =item B<--db_name>
84 DB name. (mandatory)
86 =item B<--db_user>
88 DB user name.
90 =item B<--db_passwd>
92 DB password.
94 =item B<--db_driver>
96 DB driver to be used. (defaults to 'mysql')
98 =item B<--db_host>
100 hostname for the DB server. (defaults to 'localhost')
102 =item B<--db_port>
104 port number for the DB server. (defaults to '3306')
106 =item B<--path>
108 path into which create the schema files. (defaults to './')
110 =item B<-h|--help>
112 prints this help text
114 =back