-- CREATE FIELD "affectedOrganizationID" -----------------------
ALTER TABLE `smd__user_has_events` ADD COLUMN `affectedOrganizationID` Int( 10 ) UNSIGNED NULL;
-- -------------------------------------------------------------

-- CREATE INDEX "index_affectedOrganizationID" -----------------
CREATE INDEX `index_affectedOrganizationID` ON `smd__user_has_events`( `affectedOrganizationID` );
-- -------------------------------------------------------------

-- CREATE LINK "lnk_smd__organization_smd__user_has_events" ----
ALTER TABLE `smd__user_has_events`
    ADD CONSTRAINT `lnk_smd__organization_smd__user_has_events` FOREIGN KEY ( `affectedOrganizationID` )
        REFERENCES `smd__organization`( `organizationID` )
        ON DELETE Set NULL
        ON UPDATE Cascade;
-- -------------------------------------------------------------

ALTER TABLE `smd__user_has_events`
    ADD CONSTRAINT `lnk_cms__user_smd__user_has_events` FOREIGN KEY ( `userID` )
        REFERENCES `cms__user`( `userID` )
        ON DELETE Cascade
        ON UPDATE Cascade;