12

IT'S CAPS RANT TIME!
MYSQL ERRORS ARE SO USELESS! AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHH

I JUST WANT TO ADD A FOREIGN KEY BUT 'Cannot add foreign key constraint' KEEPS COMING UP, AND THE STACK OVERFLOW ANSWERS INDICATE THAT IT COULD BE -LITERALLY- ANYTHING!

THIS IS OF COURSE, AFTER PHPMYADMIN GIVES ITS OWN ERRORS FOR TRYING TO USE THE DESIGNER TO ADD THE RELATION. IT ONLY WANTS UNIQUE FOREIGN KEYS, DESPITE ONE OF THE MAIN USES OF FOREIGN KEYS BEING MANY-TO-MANY AND ONE-TO-MANY RELATIONS!

Comments
  • 5
    Are both parent and child the same data type?

    Try creating a copy of the tables with no data and see if it will add?

    FKs suck when they don’t create, they suck more if you need to delete things.
  • 3
    @C0D4 Managed to fix it. Makes me feel stupid for missing it. One table's engine was not InnoDB (after I ran a bunch of statements to change all the table engines). Must have missed it. After that my statements were wrong, but I found that anyway. Again, if the damn errors were less cryptic I wouldn't have spent an hour on this.
  • 4
    @TheCapeGreek can’t say I’ve had that issue before 😂

    MySQL and it’s cryptic error are the best. You have an error “somewhere”
Add Comment