I am looking to standardize fields in my database. How would I do the following, where the field has a FK constraint to it:
In django:
Platform.objects.filter(name='ITUNES').update(name='iTunes')
# gives FK error
In mysql:
update main_platform set name='iTunes' where name='ITUNES'
# Cannot delete or update a parent row: a foreign key constraint fails (`avails`.`main_credit`, CONSTRAINT `main_credit_ibfk_3` FOREIGN KEY (`platform_id`) REFERENCES `main_platform` (`name`))
What would be the solution for this?
Please note that I'm not looking to add additional fields, such as an ID field, where the FK will never change, I'm only interested in updating the existing field.
The current table I have for the Platform is:
CREATE TABLE `main_platform` (
`name` varchar(20) NOT NULL,
`guid` varchar(40) DEFAULT NULL,
PRIMARY KEY (`name`),
KEY `guid` (`guid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;