X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=sql%2FPg-upgrade2%2Fglobalprojectnumber_ap_ar_oe.pl;h=f12c92a52bb69d3f2df6c80258779021bdbe7763;hb=eb496376260c7360d5bc53d865c38d47a9685fda;hp=93ace03ee84e1cebd69210898dbb84a9eb279359;hpb=b4231065f28f384a489240b9b619a098a895c22c;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl b/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl
index 93ace03ee..f12c92a52 100644
--- a/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl
+++ b/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl
@@ -1,26 +1,16 @@
# @tag: globalprojectnumber_ap_ar_oe
# @description: Neue Spalte für eine globale Projektnummer in Einkaufs- und Verkaufsbelegen
# @depends: release_2_4_1
+package SL::DBUpgrade2::globalprojectnumber_ap_ar_oe;
-die("This script cannot be run from the command line.") unless ($main::form);
+use strict;
+use utf8;
-sub mydberror {
- my ($msg) = @_;
- die($dbup_locale->text("Database update error:") .
- "
$msg
" . $DBI::errstr);
-}
-
-sub do_query {
- my ($query, $may_fail) = @_;
+use parent qw(SL::DBUpgrade2::Base);
- if (!$dbh->do($query)) {
- mydberror($query) unless ($may_fail);
- $dbh->rollback();
- $dbh->begin_work();
- }
-}
+sub run {
+ my ($self) = @_;
-sub do_update {
my @queries =
("ALTER TABLE ap ADD COLUMN globalproject_id integer;",
"ALTER TABLE ap ADD FOREIGN KEY (globalproject_id) REFERENCES project (id);",
@@ -29,11 +19,10 @@ sub do_update {
"ALTER TABLE oe ADD COLUMN globalproject_id integer;",
"ALTER TABLE oe ADD FOREIGN KEY (globalproject_id) REFERENCES project (id);");
- do_query("ALTER TABLE project ADD PRIMARY KEY (id);", 1);
- map({ do_query($_, 0); } @queries);
+ $self->db_query("ALTER TABLE project ADD PRIMARY KEY (id)", may_fail => 1);
+ $self->db_query($_) for @queries;
return 1;
}
-return do_update();
-
+1;