ALTER TABLE `cf_Media` ADD `revisionStart` INT NULL AFTER `partId` ,
ADD `revisionEnd` INT NULL AFTER `revisionStart` ;

UPDATE cf_Media m SET revisionStart = (SELECT MIN(id) FROM cf_PartVersion pv WHERE pv.partId = m.partId);