From 1e2a4a3836d317a33166b34f514ca6863e4824c1 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 20 Feb 2007 16:14:56 +0000 Subject: [PATCH] =?utf8?q?Anscheinend=20gab=20es=20irgendwo=20im=20Upgrade?= =?utf8?q?-Pfad=20Unstimmigkeiten,=20sodass=20nicht=20alle=20Datenbanken?= =?utf8?q?=20bei=20project=20einen=20Prim=C3=A4rschl=C3=BCssel=20auf=20id?= =?utf8?q?=20haben,=20auch=20wenn=20dieser=20in=20lx-office.sql=20eingetra?= =?utf8?q?gen=20ist.=20Also=20project=20mit=20einem=20Prim=C3=A4rschl?= =?utf8?q?=C3=BCssel=20versehen,=20sofern=20keiner=20existiert,=20bevor=20?= =?utf8?q?mit=20Fremdschl=C3=BCsseln=20darauf=20verwiesen=20wird.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../globalprojectnumber_ap_ar_oe.pl | 33 +++++++++++++++++++ .../globalprojectnumber_ap_ar_oe.sql | 9 ----- 2 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl delete mode 100644 sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.sql diff --git a/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl b/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl new file mode 100644 index 000000000..a9de59f1d --- /dev/null +++ b/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl @@ -0,0 +1,33 @@ +# @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(); + diff --git a/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.sql b/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.sql deleted file mode 100644 index 932cad4d2..000000000 --- a/sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.sql +++ /dev/null @@ -1,9 +0,0 @@ --- @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); -- 2.20.1