Open the DB using Hydra::Model::DB->new

This gets rid of the openHydraDB function and ensures that we
open the database in a consistent way.

Also drop the PostgreSQL sequence hacks.  They don't seem to be
necessary anymore.
This commit is contained in:
Eelco Dolstra
2012-03-13 12:10:19 +01:00
parent 914c5e248a
commit 179b012a8e
12 changed files with 31 additions and 79 deletions

View File

@ -2,7 +2,20 @@ package Hydra::Model::DB;
use strict;
use base 'Catalyst::Model::DBIC::Schema';
use Hydra::Helper::Nix;
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';
die "The Hydra database ($path) not exist!\n" unless -f $path;
return "dbi:SQLite:$path";
}
__PACKAGE__->config(
schema_class => 'Hydra::Schema',