2008-11-25 11:01:42 +00:00
|
|
|
package Hydra::Model::DB;
|
2008-10-28 10:19:31 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use base 'Catalyst::Model::DBIC::Schema';
|
2012-03-13 11:10:19 +00:00
|
|
|
|
|
|
|
sub getHydraPath {
|
|
|
|
my $dir = $ENV{"HYDRA_DATA"} || "/var/lib/hydra";
|
|
|
|
die "The HYDRA_DATA directory ($dir) does not exist!\n" unless -d $dir;
|
|
|
|
return $dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub getHydraDBPath {
|
|
|
|
my $db = $ENV{"HYDRA_DBI"};
|
|
|
|
return $db if defined $db;
|
|
|
|
my $path = getHydraPath . '/hydra.sqlite';
|
2012-03-19 03:57:11 +00:00
|
|
|
#warn "The Hydra database ($path) does not exist!\n" unless -f $path;
|
2012-03-13 11:10:19 +00:00
|
|
|
return "dbi:SQLite:$path";
|
|
|
|
}
|
2008-10-28 10:19:31 +00:00
|
|
|
|
|
|
|
__PACKAGE__->config(
|
2008-11-25 11:01:42 +00:00
|
|
|
schema_class => 'Hydra::Schema',
|
2012-03-12 18:42:59 +00:00
|
|
|
connect_info => {
|
2013-02-25 20:20:52 +00:00
|
|
|
dsn => getHydraDBPath
|
2012-03-12 18:42:59 +00:00
|
|
|
},
|
2008-10-28 10:19:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2008-11-25 11:01:42 +00:00
|
|
|
Hydra::Model::DB - Catalyst DBIC Schema Model
|
2008-10-28 10:19:31 +00:00
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2008-11-25 11:01:42 +00:00
|
|
|
See L<Hydra>
|
2008-10-28 10:19:31 +00:00
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
2008-11-25 11:01:42 +00:00
|
|
|
L<Catalyst::Model::DBIC::Schema> Model using schema L<Hydra::Schema>
|
2008-10-28 10:19:31 +00:00
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Eelco Dolstra
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify
|
|
|
|
it under the same terms as Perl itself.
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
1;
|