I have a tb_denunciation
with a denouncer_id int(10) unsigned
column with a foreign key referencing the tb_user(user_id)
.
I need to add NOT NULL to the denouncer_id
. I already checked that there are no null values in this column and (of course, there's a foreign key) all denouncer_id
values match to some user_id
on the tb_user
.
I'm running this command:
ALTER TABLE tb_denunciation MODIFY denouncer_id int(10) unsigned not null;
And I get the error:
ERROR 1025 (HY000): Error on rename of './my_db_schema/#sql-1153_1b4133' to './my_db_schema/tb_denunciation' (errno: 150)
I've googled that this error is related do foreign keys, but all I could check is ok. Whats wrong?
I think you need to first remove the foreign key, and then do the column altering. Then you may add back the foreign key again after it's altered.