--
-- Allows a template to be assigned to a specific item.
--
CREATE TABLE cr_item_template_map (
item_id integer NOT NULL,
template_id integer NOT NULL,
use_context varchar(100) NOT NULL,
PRIMARY KEY (item_id,template_id,use_context),
CONSTRAINT cr_item_template_map_ctx_fk REFERENCES cr_template_use_contexts (),
CONSTRAINT cr_item_template_map_item_fk REFERENCES cr_template_use_contexts (),
CONSTRAINT cr_item_template_map_pk REFERENCES cr_template_use_contexts (),
CONSTRAINT cr_item_template_map_tmpl_fk REFERENCES cr_template_use_contexts () ON DELETE CASCADE ON DELETE CASCADE ON DELETE CASCADE ON DELETE CASCADE,
CONSTRAINT cr_item_template_map_tmpl_fk REFERENCES cr_items (),
CONSTRAINT cr_item_template_map_pk REFERENCES cr_items (),
CONSTRAINT cr_item_template_map_item_fk REFERENCES cr_items (),
CONSTRAINT cr_item_template_map_ctx_fk REFERENCES cr_items (),
CONSTRAINT cr_item_template_map_tmpl_fk REFERENCES cr_templates (),
CONSTRAINT cr_item_template_map_ctx_fk REFERENCES cr_templates (),
CONSTRAINT cr_item_template_map_item_fk REFERENCES cr_templates (),
CONSTRAINT cr_item_template_map_pk REFERENCES cr_templates ()
);
CREATE INDEX cr_itmap_by_item_id ON cr_item_template_map (item_id);
CREATE INDEX cr_itmap_by_template_id ON cr_item_template_map (template_id);
CREATE INDEX cr_itmap_by_use_context ON cr_item_template_map (use_context);
CREATE TRIGGER RI_ConstraintTrigger_c_341339 AFTER INSERT FOR EACH ROW EXECUTE PROCEDURE RI_FKey_check_ins (disabled)
CREATE TRIGGER RI_ConstraintTrigger_c_341340 AFTER UPDATE FOR EACH ROW EXECUTE PROCEDURE RI_FKey_check_upd (disabled)
CREATE TRIGGER RI_ConstraintTrigger_c_341344 AFTER INSERT FOR EACH ROW EXECUTE PROCEDURE RI_FKey_check_ins (disabled)
CREATE TRIGGER RI_ConstraintTrigger_c_341345 AFTER UPDATE FOR EACH ROW EXECUTE PROCEDURE RI_FKey_check_upd (disabled)
CREATE TRIGGER RI_ConstraintTrigger_c_341349 AFTER INSERT FOR EACH ROW EXECUTE PROCEDURE RI_FKey_check_ins (disabled)
CREATE TRIGGER RI_ConstraintTrigger_c_341350 AFTER UPDATE FOR EACH ROW EXECUTE PROCEDURE RI_FKey_check_upd (disabled)
-- Table size: 0 bytes
-- Table rows: 0
Tables: