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