# Foreign key constraint issues with Pt-online schema change

**URL:** <https://forums.percona.com/t/foreign-key-constraint-issues-with-pt-online-schema-change/35578>\
**Category:** MySQL & MariaDB\
**Created:** [December 10, 2024, 12:41pm UTC](https://forums.percona.com/t/foreign-key-constraint-issues-with-pt-online-schema-change/35578 "2024-12-10T12:41:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)\
**Post date:** [December 10, 2024, 12:41pm UTC](https://forums.percona.com/t/foreign-key-constraint-issues-with-pt-online-schema-change/35578/1 "2024-12-10T12:41:12Z")

</div>

I got this error when I tried to use pt-Osc some of the solutions I am thinking about is to drop the foreign key and recreate it later.

DBD::Mysql::db do failed: cannot delete or update a parent row : a foreign key constraint fails for statements. Here I’m trying to use the pt-online schema change and I have tried all the available options, using this tool. Any suggestions

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [December 10, 2024, 1:20pm UTC](https://forums.percona.com/t/foreign-key-constraint-issues-with-pt-online-schema-change/35578/2 "2024-12-10T13:20:28Z")

</div>

Hello @Dba1,  
It would be helpful if you provided some output, and the command used, and the error you see. Also, the schema of the table will help. There is an option in pt-osc to drop FKs, and then recreate them after the ALTER is complete. Did you try that?

---

<div class="post-metadata">

**Author:** ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)\
**Post date:** [December 11, 2024, 2:36pm UTC](https://forums.percona.com/t/foreign-key-constraint-issues-with-pt-online-schema-change/35578/3 "2024-12-11T14:36:48Z")

</div>

I think the answer is that Mariadb doesn’t support FK on a partitioned table. I see it!

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [December 11, 2024, 7:15pm UTC](https://forums.percona.com/t/foreign-key-constraint-issues-with-pt-online-schema-change/35578/4 "2024-12-11T19:15:23Z")

</div>

Ah. I didn’t realize this was MariaDB; you didn’t mention that above. Good catch! You can switch to Percona Server MySQL as a drop-in replacement (provided you have no Aria tables) to gain this feature.
