ALTER TABLE `hedera`.`imageCollection`
    ADD writeRoleFk INT UNSIGNED NULL DEFAULT 1;

ALTER TABLE `hedera`.`imageCollection`
    ADD CONSTRAINT role_id_writeRoleFk
        FOREIGN KEY (writeRoleFk) REFERENCES account.role (id)
            ON UPDATE CASCADE;

ALTER TABLE `hedera`.`imageCollection` modify readRoleFk INT UNSIGNED default 1 null;

ALTER TABLE `hedera`.`imageCollection`
    ADD CONSTRAINT role_id_readRoleFk
        FOREIGN KEY (readRoleFk) REFERENCES account.role (id)
            ON UPDATE CASCADE;

UPDATE hedera.imageCollection t SET t.writeRoleFk = (
    SELECT id FROM `account`.`role` WHERE name = 'catalogPhotos'
)
WHERE t.name = 'catalog';

UPDATE hedera.imageCollection t SET t.writeRoleFk = (
    SELECT id FROM `account`.`role` WHERE name = 'userPhotos'
) 
WHERE t.name = 'user';

UPDATE hedera.imageCollection t SET t.writeRoleFk = 9
WHERE t.name IN ('link', 'news');
