Commit 1f0caaac authored by Frank Bergmann's avatar Frank Bergmann

- added if exists to avoid errors

parent f01e8fc7
......@@ -10,32 +10,33 @@
-- functions although the create script do not define this triggers.
-- It seems that an update script was missing.
--
DROP TRIGGER cr_folder_del_ri_trg ON cr_items;
DROP FUNCTION cr_folder_del_ri_trg();
DROP TRIGGER if exists cr_folder_del_ri_trg ON cr_items;
DROP FUNCTION if exists cr_folder_del_ri_trg();
DROP TRIGGER cr_folder_ins_up_ri_trg ON cr_folders;
DROP FUNCTION cr_folder_ins_up_ri_trg();
DROP TRIGGER if exists cr_folder_ins_up_ri_trg ON cr_folders;
DROP FUNCTION if exists cr_folder_ins_up_ri_trg();
--
-- Handle latest_revision and live_revision via foreign keys
--
ALTER TABLE cr_items DROP CONSTRAINT cr_items_latest_fk;
ALTER TABLE cr_items DROP CONSTRAINT if exists cr_items_latest_fk;
ALTER TABLE cr_items ADD CONSTRAINT cr_items_latest_fk
FOREIGN KEY (latest_revision) REFERENCES cr_revisions(revision_id);
ALTER TABLE cr_items DROP CONSTRAINT cr_items_live_fk;
ALTER TABLE cr_items DROP CONSTRAINT if exists cr_items_live_fk;
ALTER TABLE cr_items ADD CONSTRAINT cr_items_live_fk
FOREIGN KEY (live_revision) REFERENCES cr_revisions(revision_id);
DROP TRIGGER cr_revision_del_ri_tr on cr_items;
DROP FUNCTION cr_revision_del_ri_tr();
DROP TRIGGER if exists cr_revision_del_ri_tr on cr_items;
DROP FUNCTION if exists cr_revision_del_ri_tr();
DROP TRIGGER cr_revision_ins_ri_tr on cr_items;
DROP FUNCTION cr_revision_ins_ri_tr();
DROP TRIGGER if exists cr_revision_ins_ri_tr on cr_items;
DROP FUNCTION if exists cr_revision_ins_ri_tr();
DROP TRIGGER cr_revision_up_ri_tr on cr_items;
DROP FUNCTION cr_revision_up_ri_tr();
DROP TRIGGER if exists cr_revision_up_ri_tr on cr_items;
DROP FUNCTION if exists cr_revision_up_ri_tr();
DROP TRIGGER if exists cr_revision_del_rev_ri_tr on cr_revisions;
DROP FUNCTION if exists cr_revision_del_rev_ri_tr();
DROP TRIGGER cr_revision_del_rev_ri_tr on cr_revisions;
DROP FUNCTION cr_revision_del_rev_ri_tr();
......@@ -26,44 +26,44 @@
-- constraints from acs-content-repository/sql/postgresql/content-revision.sql
ALTER TABLE cr_item_publish_audit DROP CONSTRAINT cr_item_publish_audit_orev_fk;
ALTER TABLE cr_item_publish_audit DROP CONSTRAINT if exists cr_item_publish_audit_orev_fk;
ALTER TABLE cr_item_publish_audit ADD CONSTRAINT cr_item_publish_audit_orev_fk
FOREIGN KEY (old_revision) REFERENCES cr_revisions(revision_id) ON DELETE CASCADE;
ALTER TABLE cr_item_publish_audit DROP CONSTRAINT cr_item_publish_audit_nrev_fk;
ALTER TABLE cr_item_publish_audit DROP CONSTRAINT if exists cr_item_publish_audit_nrev_fk;
ALTER TABLE cr_item_publish_audit ADD CONSTRAINT cr_item_publish_audit_nrev_fk
FOREIGN KEY (new_revision) REFERENCES cr_revisions(revision_id) ON DELETE CASCADE;
-- constraints from acs-content-repository/sql/postgresql/content-item.sql
ALTER TABLE cr_release_periods DROP CONSTRAINT cr_release_periods_item_id_fk;
ALTER TABLE cr_release_periods DROP CONSTRAINT if exists cr_release_periods_item_id_fk;
ALTER TABLE cr_release_periods ADD CONSTRAINT cr_release_periods_item_id_fk
FOREIGN KEY (item_id) REFERENCES cr_items(item_id) ON DELETE CASCADE;
ALTER TABLE cr_item_publish_audit DROP CONSTRAINT cr_item_publish_audit_item_fk;
ALTER TABLE cr_item_publish_audit DROP CONSTRAINT if exists cr_item_publish_audit_item_fk;
ALTER TABLE cr_item_publish_audit ADD CONSTRAINT cr_item_publish_audit_item_fk
FOREIGN KEY (item_id) REFERENCES cr_items(item_id) ON DELETE CASCADE;
ALTER TABLE cr_item_template_map DROP CONSTRAINT cr_item_template_map_item_fk;
ALTER TABLE cr_item_template_map DROP CONSTRAINT if exists cr_item_template_map_item_fk;
ALTER TABLE cr_item_template_map ADD CONSTRAINT cr_item_template_map_item_fk
FOREIGN KEY (item_id) REFERENCES cr_items(item_id) ON DELETE CASCADE;
ALTER TABLE cr_item_keyword_map DROP CONSTRAINT cr_item_keyword_map_item_id_fk;
ALTER TABLE cr_item_keyword_map DROP CONSTRAINT if exists cr_item_keyword_map_item_id_fk;
ALTER TABLE cr_item_keyword_map ADD CONSTRAINT cr_item_keyword_map_item_id_fk
FOREIGN KEY (item_id) REFERENCES cr_items(item_id) ON DELETE CASCADE;
ALTER TABLE cr_items DROP CONSTRAINT cr_items_latest_fk;
ALTER TABLE cr_items DROP CONSTRAINT if exists cr_items_latest_fk;
ALTER TABLE cr_items ADD CONSTRAINT cr_items_latest_fk
FOREIGN KEY (latest_revision) REFERENCES cr_revisions(revision_id) on delete set null;
ALTER TABLE cr_items DROP CONSTRAINT cr_items_live_fk;
ALTER TABLE cr_items DROP CONSTRAINT if exists cr_items_live_fk;
ALTER TABLE cr_items ADD CONSTRAINT cr_items_live_fk
FOREIGN KEY (live_revision) REFERENCES cr_revisions(revision_id) on delete set null;
DROP INDEX CR_CHILD_RELS_kids_IDx;
DROP INDEX cr_child_rels_child_id_idx;
DROP INDEX if exists CR_CHILD_RELS_kids_IDx;
DROP INDEX if exists cr_child_rels_child_id_idx;
CREATE INDEX cr_child_rels_child_id_idx on cr_child_rels(child_id);
--
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment