1 |
61029
|
alessia.ba
|
BEGIN;
|
2 |
|
|
-- Add constraint to FK
|
3 |
|
|
ALTER TABLE dsm_organizationpids DROP CONSTRAINT dsm_organizationpids_pid_fkey;
|
4 |
|
|
ALTER TABLE dsm_organizationpids ADD CONSTRAINT dsm_organizationpids_pid_fkey
|
5 |
|
|
FOREIGN KEY (pid) REFERENCES dsm_identities (pid)
|
6 |
|
|
ON UPDATE CASCADE;
|
7 |
|
|
-- Update
|
8 |
|
|
UPDATE dsm_identities
|
9 |
|
|
set pid = substring(pid,5)
|
10 |
|
|
where issuertype ='PIC';
|
11 |
|
|
-- Add original FK
|
12 |
|
|
ALTER TABLE dsm_organizationpids DROP CONSTRAINT dsm_organizationpids_pid_fkey;
|
13 |
|
|
ALTER TABLE dsm_organizationpids ADD CONSTRAINT dsm_organizationpids_pid_fkey
|
14 |
|
|
FOREIGN KEY (pid) REFERENCES dsm_identities (pid);
|
15 |
|
|
COMMIT
|
16 |
|
|
;
|