Fix DB-Upgrade »Wiedervorlagen löschen, wenn dazugehörige Belege gelöscht werden«
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 7 Jan 2014 08:43:35 +0000 (09:43 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 7 Jan 2014 08:43:35 +0000 (09:43 +0100)
Wenn Datenbanken mit älteren PostgreSQL-Versionen angelegt wurden,
dann kann es sein, dass die FKEY-Constraint anders benannt war.

sql/Pg-upgrade2/delete_close_follow_ups_when_order_is_deleted_closed.sql
sql/Pg-upgrade2/delete_close_follow_ups_when_order_is_deleted_closed_fkey_deletion.pl [new file with mode: 0644]

index e13a7bd..f2963f5 100644 (file)
@@ -1,9 +1,8 @@
 -- @tag: delete_close_follow_ups_when_order_is_deleted_closed
 -- @description: Wiedervorlagen löschen/schließen, wenn dazugehörige Belege gelöscht/geschlossen werden
--- @depends: release_3_0_0
+-- @depends: delete_close_follow_ups_when_order_is_deleted_closed_fkey_deletion
 
-ALTER TABLE follow_up_links DROP CONSTRAINT follow_up_links_follow_up_id_fkey;
-ALTER TABLE follow_up_links ADD FOREIGN KEY (follow_up_id) REFERENCES follow_ups (id) ON DELETE CASCADE;
+ALTER TABLE follow_up_links ADD CONSTRAINT follow_up_links_follow_up_id_fkey FOREIGN KEY (follow_up_id) REFERENCES follow_ups (id) ON DELETE CASCADE;
 
 CREATE OR REPLACE FUNCTION follow_up_delete_notes_trigger()
 RETURNS TRIGGER AS $$
diff --git a/sql/Pg-upgrade2/delete_close_follow_ups_when_order_is_deleted_closed_fkey_deletion.pl b/sql/Pg-upgrade2/delete_close_follow_ups_when_order_is_deleted_closed_fkey_deletion.pl
new file mode 100644 (file)
index 0000000..1e41817
--- /dev/null
@@ -0,0 +1,19 @@
+# @tag: delete_close_follow_ups_when_order_is_deleted_closed_fkey_deletion
+# @description: delete_close_follow_ups_when_order_is_deleted_closed_fkey_deletion
+# @depends: release_3_0_0
+package SL::DBUpgrade2::delete_close_follow_ups_when_order_is_deleted_closed_fkey_deletion;
+
+use strict;
+use utf8;
+
+use parent qw(SL::DBUpgrade2::Base);
+
+sub run {
+  my ($self) = @_;
+
+  $self->drop_constraints(table => "follow_up_links");
+
+  return 1;
+}
+
+1;