sábado, 30 de abril de 2016

Cannot change column used in a foreign key constraint

Cuando tienes el error Cannot change colum '***': used in a foreign key constraint

Error Code: 1833. Cannot change column 'person_id': used in a foreign key constraint 'fk_fav_food_person_id' of table 'table.favorite_food'


La solución es bloquear las tablas y después modificar la foreign key:
LOCK TABLES favorite_food WRITE, person WRITE;

ALTER TABLE favorite_food ADD FOREIGN KEY CONSTRAINT fk_fav_food_person_id FOREIGN KEY (person_id)

UNLOCK TABLES;

No hay comentarios:

Publicar un comentario