Revision 4ee840f4
Von Werner Hahn vor mehr als 7 Jahren hinzugefügt
sql/Pg-upgrade2/shop_orders_update_1.sql | ||
---|---|---|
1 |
-- @tag: shop_orders_update_1 |
|
2 |
-- @description: Ändern der Tabellen shop_orders und shop_order_items. Trigger für oe |
|
3 |
-- @depends: release_3_4_1 shop_orders shop_orders_add_active_price_source |
|
4 |
-- @ignore: 1 |
|
5 |
|
|
6 |
ALTER TABLE shop_orders ADD FOREIGN KEY (shop_id) REFERENCES shops(id); |
|
7 |
ALTER TABLE shop_orders ADD FOREIGN KEY (kivi_customer_id) REFERENCES customer(id); |
|
8 |
ALTER TABLE shop_orders DROP COLUMN shop_data; |
|
9 |
ALTER TABLE shop_order_items DROP COLUMN shop_id; |
|
10 |
|
|
11 |
CREATE OR REPLACE FUNCTION update_shop_orders_on_delete_oe() RETURNS TRIGGER AS $$ |
|
12 |
BEGIN |
|
13 |
UPDATE shop_orders SET oe_trans_id = NULL WHERE oe_trans_id = OLD.id; |
|
14 |
|
|
15 |
RETURN OLD.id; |
|
16 |
END; |
|
17 |
$$ LANGUAGE plpgsql; |
|
18 |
|
|
19 |
CREATE TRIGGER after_delete_oe_trigger |
|
20 |
AFTER DELETE ON oe FOR EACH ROW EXECUTE |
|
21 |
PROCEDURE update_shop_orders_on_delete_oe(); |
Auch abrufbar als: Unified diff
Shopmodul: sql updatedatei Änderunegn in Tabellen shop_order
shop_order_items Trigger/funktion um spalte oe_trans_id auf null zu
setzten wenn der dazugehörige Auftrag gelöscht wird