Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

What probably could also help: If there is a key on the foreign table affecting the field to be used as foreign key: recreate that index. (Not tested)

...

Solutions for case 2:

Solution A - inconsistent data types / collations / encodings

See https://stackoverflow.com/questions/16969060/mysql-error-1215-cannot-add-foreign-key-constraint

One example to get the error: 

  1. Livesystem DB System or DB itself is using encoding and/or collation A as default
  2. Testsystem DB System or DB itself is using encoding and/or collation B as default
  3. User makes a dump from live and applies it to Testsystem
  4. User then tries to update the Testsystem
    1. The dump from live creates table LEK_task with encoding/collation A
    2. The Update tries to create table XYZ with collation B
  5. => Result: the foreign key could not be created

Solution B - innoDB foreign keys corrupt

In that case the error happened on Updating data in the LEK_term_attributes table. Error was:

...