Revision 4ffe46ac
Von Bernd Bleßmann vor fast 11 Jahren hinzugefügt
sql/Pg-upgrade2/delete_translations_on_delivery_term_delete.sql | ||
---|---|---|
1 |
-- @tag: delete_translations_on_delivery_term_delete |
|
2 |
-- @description: Übersetzungen löschen, wenn Lieferbedingung gelöscht wird |
|
3 |
-- @depends: delivery_terms |
|
4 |
-- @encoding: utf-8 |
|
5 |
|
|
6 |
CREATE OR REPLACE FUNCTION generic_translations_delete_on_delivery_terms_delete_trigger() |
|
7 |
RETURNS TRIGGER AS $$ |
|
8 |
BEGIN |
|
9 |
DELETE FROM generic_translations |
|
10 |
WHERE translation_id = OLD.id AND translation_type LIKE 'SL::DB::DeliveryTerm/description_long'; |
|
11 |
RETURN OLD; |
|
12 |
END; |
|
13 |
$$ LANGUAGE plpgsql; |
|
14 |
|
|
15 |
DROP TRIGGER IF EXISTS after_delete_delivery_term_trigger ON delivery_terms; |
|
16 |
|
|
17 |
CREATE TRIGGER after_delete_delivery_term_trigger |
|
18 |
AFTER DELETE ON delivery_terms |
|
19 |
FOR EACH ROW EXECUTE PROCEDURE generic_translations_delete_on_delivery_terms_delete_trigger(); |
|
20 |
|
|
21 |
-- delete orphaned translations |
|
22 |
DELETE FROM generic_translations |
|
23 |
WHERE translation_type LIKE 'SL::DB::DeliveryTerm/description_long' |
|
24 |
AND translation_id NOT IN (SELECT id FROM delivery_terms); |
Auch abrufbar als: Unified diff
Übersetzungen von Lieferbedingungen löschen, wenn Lieferbed. gelöscht wird.
Via Trigger. Außerdem löscht das Update-Skript alle verweisten Übersetzungen
der Lieferbedingungen.