From: Moritz Bunkus Date: Wed, 4 Jul 2007 07:35:43 +0000 (+0000) Subject: Datenbankupgrade: Die Spalte 'storno_id' in 'ar' und 'ap' sollte auch gefüllt werden. X-Git-Tag: release-2.4.3^2~51 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=7e73a793af79a09aa48973d06830e6fc4ef38a2e;p=kivitendo-erp.git Datenbankupgrade: Die Spalte 'storno_id' in 'ar' und 'ap' sollte auch gefüllt werden. --- diff --git a/sql/Pg-upgrade2/ar_ap_storno_id.sql b/sql/Pg-upgrade2/ar_ap_storno_id.sql new file mode 100644 index 000000000..d4fb89051 --- /dev/null +++ b/sql/Pg-upgrade2/ar_ap_storno_id.sql @@ -0,0 +1,26 @@ +-- @tag: ar_ap_storno_id +-- @description: Füllen der Spalte 'storno_id' in den Tabellen 'ar' und 'ap' +-- @depends: ar_storno ap_storno +UPDATE ar SET storno_id = + (SELECT id + FROM ar ar2 + WHERE ar2.storno + AND ('Storno zu ' || ar2.invnumber = ar.invnumber) + AND (ar2.id < ar.id) + ORDER BY id DESC + LIMIT 1) + WHERE storno + AND (COALESCE(storno_id, 0) = 0) + AND (invnumber LIKE 'Storno zu %'); + +UPDATE ap SET storno_id = + (SELECT id + FROM ap ap2 + WHERE ap2.storno + AND ('Storno zu ' || ap2.invnumber = ap.invnumber) + AND (ap2.id < ap.id) + ORDER BY id DESC + LIMIT 1) + WHERE storno + AND (COALESCE(storno_id, 0) = 0) + AND (invnumber LIKE 'Storno zu %');