Revision de8868cb
Von Moritz Bunkus vor etwa 13 Jahren hinzugefügt
sql/Pg-upgrade2/customer_add_constraints.sql | ||
---|---|---|
4 | 4 |
-- @charset: utf-8 |
5 | 5 |
-- @ignore: 0 |
6 | 6 |
|
7 |
-- verwaiste Zahlungsbedingungen vorher entfernen: |
|
8 |
update customer set payment_id = NULL where payment_id not in (select id from payment_terms); |
|
7 |
-- verwaiste Einträge vorher entfernen |
|
8 |
UPDATE customer SET payment_id = NULL WHERE payment_id NOT IN (SELECT id FROM payment_terms); |
|
9 |
UPDATE customer SET language_id = NULL WHERE language_id NOT IN (SELECT id FROM language); |
|
10 |
UPDATE customer SET business_id = NULL WHERE business_id NOT IN (SELECT id FROM business); |
|
9 | 11 |
|
10 | 12 |
ALTER TABLE customer ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id); |
11 | 13 |
ALTER TABLE customer ADD FOREIGN KEY (language_id) REFERENCES language (id); |
sql/Pg-upgrade2/vendor_add_constraints.sql | ||
---|---|---|
4 | 4 |
-- @charset: utf-8 |
5 | 5 |
-- @ignore: 0 |
6 | 6 |
|
7 |
-- verwaiste Zahlungsbedingungen vorher entfernen |
|
8 |
update vendor set payment_id = NULL where payment_id not in (select id from payment_terms); |
|
9 |
|
|
7 |
-- verwaiste Einträge vorher entfernen |
|
8 |
UPDATE vendor SET payment_id = NULL WHERE payment_id NOT IN (SELECT id FROM payment_terms); |
|
9 |
UPDATE vendor SET language_id = NULL WHERE language_id NOT IN (SELECT id FROM language); |
|
10 |
UPDATE vendor SET business_id = NULL WHERE business_id NOT IN (SELECT id FROM business); |
|
10 | 11 |
|
11 | 12 |
ALTER TABLE vendor ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id); |
12 | 13 |
ALTER TABLE vendor ADD FOREIGN KEY (language_id) REFERENCES language (id); |
Auch abrufbar als: Unified diff
Constraints auf vendor/customer: Vorher alle verwaisten Einträge entfernen