metricsign
Start free
High severitydata integrity

Power BI Refresh Error:
1215

What does this error mean?

An ALTER TABLE or CREATE TABLE failed to add a FK constraint — usually due to a missing index or data type mismatch.

Common causes

  • 1The referenced column in the parent table has no index (MySQL requires an index on the referenced column)
  • 2Data type mismatch between child FK column and parent referenced column (e.g., INT vs BIGINT)
  • 3Character set or collation mismatch between the two columns
  • 4Existing data in the child column has values with no matching parent row

How to fix it

  1. 1Step 1: Check that the referenced parent column has an index: `SHOW INDEX FROM parent_table;` — add one if missing: `ALTER TABLE parent_table ADD INDEX (referenced_col);`
  2. 2Step 2: Verify data types match exactly: `DESCRIBE child_table;` and `DESCRIBE parent_table;` — both FK and referenced columns must have identical type, length, and sign.
  3. 3Step 3: Check for orphaned data: `SELECT child.fk_col FROM child LEFT JOIN parent ON child.fk_col=parent.id WHERE parent.id IS NULL;`
  4. 4Step 4: Temporarily use `SET FOREIGN_KEY_CHECKS=0;` to add the constraint definition, then fix data, then re-enable.

Frequently asked questions

How do I see the exact reason MySQL rejected my FK constraint?

Run `SHOW ENGINE INNODB STATUS;` immediately after the error. The LATEST FOREIGN KEY ERROR section shows the detailed reason including data type mismatches.

Does MySQL automatically create an index for FK columns?

MySQL automatically creates an index on the child FK column if one does not exist. It does NOT create an index on the parent referenced column — you must add that manually.

Can MetricSign help monitor FK-related migration failures?

Yes — when a dbt or ADF pipeline fails due to a schema constraint issue, MetricSign surfaces the MySQL error code in the incident detail.

Official documentation: https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html

Other data integrity errors