X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bin%2Fdebbugs-installsql;h=ed407eba65b34e2bf66541ba72f8ef5b8751041e;hb=084a31cbcee60e2f6de32d824aaec408018cd1d5;hp=1156f178362e6cc40a58c16889ade459d68a302d;hpb=1012ca820421c8b27e8fc9ae916b059d011c171a;p=debbugs.git diff --git a/bin/debbugs-installsql b/bin/debbugs-installsql index 1156f17..ed407eb 100755 --- a/bin/debbugs-installsql +++ b/bin/debbugs-installsql @@ -76,6 +76,7 @@ use if (-d $FindBin::Bin.'/../.git/' && $INC[0] =~ m#^/#), lib => $FindBin::Bin.'/../lib/'; use Debbugs::DB; +use JSON; my %options = (debug => 0, help => 0, @@ -136,18 +137,28 @@ my $s = Debbugs::DB->connect($options{dsn}) or if ($options{current_version}) { - print "The current database version is: ".$s->database_version."\n"; + print "The current database version is: ".$s->db_version."\n"; exit 0; } elsif ($options{install}) { $s->sql_file_in_txn($options{deployment_dir}.'/debbugs_schema.sql'); } elsif ($options{upgrade}) { - my @upgrades = $s->upgrades_to_run($options{deployment_dir}); + my @upgrades = $s->upgrades_to_run($options{deployment_dir}.'/upgrade'); for my $u_f (@upgrades) { eval { - $s->sql_file_in_txn($u_f->file); + package fake; + require $u_f->{file}; + $s->txn_do(sub {fake::upgrade($s); + $s->resultset('DbVersion')-> + create({version => $u_f->{to}, + metadata => JSON::encode_json({from => $u_f->{from}+0, + to => $u_f->{to}+0, + file => $u_f->{file}, + }), + }); + }); }; if ($@) { - print STDERR "Upgrade from $s->database_version to $u_f->version failed: $@"; + print STDERR "Upgrade from $s->database_version to $u_f->{to} failed: $@"; exit 1; } }