Skip to content

Commit

Permalink
Verwijder foreign key constraints op recht.isbestemdtot, recht.isonts…
Browse files Browse the repository at this point in the history
…taanuit en recht.isbetrokkenbij
  • Loading branch information
mvdstruijk authored and mprins committed Nov 14, 2024
1 parent 46a4c7f commit afaec91
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions datamodel/upgrade_scripts/3.0.2-4.0.0/oracle/brk.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,56 @@ COMMENT ON COLUMN onroerendezaak.eindegeldigheid IS 'BRMO: metadata tbv archiver
COMMENT ON COLUMN recht.begingeldigheid IS 'BRMO: metadata tbv archivering, de toestandsdatum van het bericht.';

--https://b3partners.atlassian.net/browse/BRMO-332
-- Onderstaande alleen uitvoeren als deze constraints bestaan
-- ALTER TABLE recht DROP CONSTRAINT recht_isbestemdtot_fkey;
-- ALTER TABLE recht DROP CONSTRAINT recht_isontstaanuit_fkey;
-- ALTER TABLE recht DROP CONSTRAINT recht_isbetrokkenbij_fkey;
-- Haal de constraintnaam op uit de database. Oracle genereert geen voorspelbare namen voor constraints.
DECLARE
v_constraint_name VARCHAR2(255);
BEGIN
BEGIN
SELECT c.constraint_name
INTO v_constraint_name
FROM all_cons_columns col
JOIN all_constraints c
ON col.constraint_name = c.constraint_name
WHERE col.table_name = 'recht'
AND col.column_name = 'isbestemdtot'
AND c.constraint_type = 'R';
EXECUTE IMMEDIATE 'ALTER TABLE recht DROP CONSTRAINT ' || v_constraint_name;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Geen constraint gevonden voor recht.isbestemdtot');
END;

BEGIN
SELECT c.constraint_name
INTO v_constraint_name
FROM all_cons_columns col
JOIN all_constraints c
ON col.constraint_name = c.constraint_name
WHERE col.table_name = 'recht'
AND col.column_name = 'isontstaanuit'
AND c.constraint_type = 'R';
EXECUTE IMMEDIATE 'ALTER TABLE recht DROP CONSTRAINT ' || v_constraint_name;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Geen constraint gevonden voor recht.isontstaanuit');
END;

BEGIN
SELECT c.constraint_name
INTO v_constraint_name
FROM all_cons_columns col
JOIN all_constraints c
ON col.constraint_name = c.constraint_name
WHERE col.table_name = 'recht'
AND col.column_name = 'isbetrokkenbij'
AND c.constraint_type = 'R';
EXECUTE IMMEDIATE 'ALTER TABLE recht DROP CONSTRAINT ' || v_constraint_name;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Geen constraint gevonden voor recht.isbetrokkenbij');
END;
END;
/

--https://b3partners.atlassian.net/browse/BRMO-379
CREATE INDEX onroerendezaakfiliatie_betreft_idx ON onroerendezaakfiliatie (betreft);
Expand Down

0 comments on commit afaec91

Please sign in to comment.