X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bin%2Fdebbugs-installsql;h=8d8437ace3c219da8200a410b6618dd7fdd59991;hb=77d7273afd35f0069bdc8aea2732c725a869452b;hp=ede803cdab59870fb5355dc8c3458ae089e4fdcd;hpb=d25bde9d44991d11d405812cb50ef95ada5ad0ca;p=debbugs.git diff --git a/bin/debbugs-installsql b/bin/debbugs-installsql index ede803c..8d8437a 100755 --- a/bin/debbugs-installsql +++ b/bin/debbugs-installsql @@ -69,12 +69,12 @@ debbugs-installsql use vars qw($DEBUG); use Debbugs::DB; +use Debbugs::DB::Util qw(prepare_execute); use aliased 'DBIx::Class::DeploymentHandler' => 'DH'; my %options = (debug => 0, help => 0, man => 0, - developer_prepare => 0, overwrite_deployment => 0, service => 'debbugs', deployment_dir => '/usr/share/debbugs/sqldeployment', @@ -82,13 +82,13 @@ my %options = (debug => 0, GetOptions(\%options, 'service|s=s', + 'dsn=s', 'sysconfdir|c=s', 'install', 'install_version_storage|install-version-storage', 'upgrade', 'current_version|current-version', - 'developer_prepare|developer-prepare', - 'overwrite_deployment|overwrite-deployment', + 'overwrite_deployment|overwrite-deployment|force_overwrite|force-overwrite', 'deployment_dir|deployment-dir=s', 'debug|d+','help|h|?','man|m'); @@ -119,28 +119,46 @@ if (exists $options{sysconfdir}) { } } +if (not exists $options{dsn} or + not defined $options{dsn} or + not length $options{dsn}) { + $options{dsn} = 'dbi:Pg:service='.$options{service}; +} + -my $schema = Debbugs::DB->connect('dbi:Pg:service='.$options{service}) or +my $schema = Debbugs::DB->connect($options{dsn}) or die "Unable to connect to database"; my $dh = DH->new({schema => $schema, force_overwrite => $options{overwrite_deployment}, script_directory => $options{deployment_dir}, - databases => 'PostgreSQL' + databases => 'PostgreSQL', + sql_translator_args => {producer_args=> {postgres_version => 9}}, }); if ($options{current_version}) { print "The current database version is: ".$dh->database_version."\n"; exit 0; } elsif ($options{install}) { - if ($options{developer_prepare}) { - $dh->prepare_install; - $dh->prepare_deploy; - } else { - $dh->install; - } + $dh->prepare_install; + $dh->install; + ## this is lame, but because the current release of DeploymentHandler does + ## not support WHERE or quoted indexes properly (fixed in git), we create + ## these indexes manually here. + $schema->storage-> + dbh_do(sub{my ($s,$dbh) = @_; + prepare_execute($dbh,<prepare_deploy; $dh->prepare_upgrade; $dh->upgrade; } elsif ($options{install_version_storage}) {