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>.
23 use DBIx
::Class
::Schema
::Loader qw
/ make_schema_at /;
46 "db_driver=s" => \
$db_driver,
47 "db_host=s" => \
$db_host,
48 "db_port=s" => \
$db_port,
49 "db_name=s" => \
$db_name,
50 "db_user=s" => \
$db_user,
51 "db_passwd=s" => \
$db_passwd,
52 "koha-conf:s" => \
$koha_conf,
56 # If we were asked for usage instructions, do it
57 pod2usage
(1) if defined $help;
59 if (defined $koha_conf) {
60 if ($koha_conf eq '' and not defined $ENV{KOHA_CONF
}) {
61 print STDERR
"Error: KOHA_CONF is not defined\n";
65 $koha_conf ||= $ENV{KOHA_CONF
};
66 unless (-r
$koha_conf) {
67 print STDERR
"Error: File $koha_conf does not exist or is not readable\n";
72 my $context = C4
::Context
->new($koha_conf);
74 print STDERR
"Error: Koha context creation failed. Please check that $koha_conf is correct\n";
78 $context->set_context;
79 $db_defaults{driver
} = $context->config('db_scheme');
80 $db_defaults{host
} = $context->config('hostname');
81 $db_defaults{port
} = $context->config('port');
82 $db_defaults{name
} = $context->config('database');
83 $db_defaults{user
} = $context->config('user');
84 $db_defaults{passwd
} = $context->config('pass');
87 $db_driver //= $db_defaults{driver
};
88 $db_host //= $db_defaults{host
};
89 $db_port //= $db_defaults{port
};
90 $db_name //= $db_defaults{name
};
91 $db_user //= $db_defaults{user
};
92 $db_passwd //= $db_defaults{passwd
};
94 if (! defined $db_name ) {
95 print "Error: \'db_name\' parameter is mandatory.\n";
101 { debug
=> 1, dump_directory
=> $path, preserve_case
=> 1 },
102 ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ]
110 misc/devel/update_dbix_class_files.pl
114 update_dbix_class_files.pl [--koha-conf <path>] --db_name=db-name \
115 --db_user=db-user --db_passwd=db-pass ...
117 The command in usually called from the root directory for the Koha source tree.
118 If you are running from another directory, use the --path switch to specify
125 =item B<--koha-conf> <path>
127 Path to koha-conf.xml from which DB connection params will be retrieved.
129 <path> is optional and defaults to the value of environment variable KOHA_CONF,
130 if set. It is an error to omit the <path> if KOHA_CONF is not set.
132 Any B<--db_*> options will override values retrieved from <path>.
148 DB driver to be used. (defaults to 'mysql')
152 hostname for the DB server. (defaults to 'localhost')
156 port number for the DB server. (defaults to '3306')
160 path into which create the schema files. (defaults to './')
164 prints this help text