--- /dev/null
+# @tag: globalprojectnumber_ap_ar_oe
+# @description: Neue Spalte für eine globale Projektnummer in Einkaufs- und Verkaufsbelegen
+# @depends: release_2_4_1
+
+die("This script cannot be run from the command line.") unless ($main::form);
+
+sub do_query {
+ my ($query, $may_fail) = @_;
+
+ if (!$dbh->do($query)) {
+ mydberror($query) unless ($may_fail);
+ $dbh->rollback();
+ $dbh->begin_work();
+ }
+}
+
+sub do_update {
+ my @queries =
+ ("ALTER TABLE ap ADD COLUMN globalproject_id integer;",
+ "ALTER TABLE ap ADD FOREIGN KEY (globalproject_id) REFERENCES project (id);",
+ "ALTER TABLE ar ADD COLUMN globalproject_id integer;",
+ "ALTER TABLE ar ADD FOREIGN KEY (globalproject_id) REFERENCES project (id);",
+ "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);
+
+ return 1;
+}
+
+return do_update();
+
+++ /dev/null
--- @tag: globalprojectnumber_ap_ar_oe
--- @description: Neue Spalte für eine globale Projektnummer in Einkaufs- und Verkaufsbelegen
--- @depends: release_2_4_1
-ALTER TABLE ap ADD COLUMN globalproject_id integer;
-ALTER TABLE ap ADD FOREIGN KEY (globalproject_id) REFERENCES project (id);
-ALTER TABLE ar ADD COLUMN globalproject_id integer;
-ALTER TABLE ar ADD FOREIGN KEY (globalproject_id) REFERENCES project (id);
-ALTER TABLE oe ADD COLUMN globalproject_id integer;
-ALTER TABLE oe ADD FOREIGN KEY (globalproject_id) REFERENCES project (id);