# pt-online-schema-change drop the old and new table

**URL:** <https://forums.percona.com/t/pt-online-schema-change-drop-the-old-and-new-table/5678>\
**Category:** Percona Toolkit\
**Created:** [June 14, 2017, 1:34am UTC](https://forums.percona.com/t/pt-online-schema-change-drop-the-old-and-new-table/5678 "2017-06-14T01:34:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/hamoon/32/1170_2.png) [@Hamoon](https://forums.percona.com/u/Hamoon)\
**Post date:** [June 14, 2017, 1:34am UTC](https://forums.percona.com/t/pt-online-schema-change-drop-the-old-and-new-table/5678/1 "2017-06-14T01:34:35Z")

</div>

Correct Title: pt-online-schema-change dropped the old and new table and I lost the data  
Hello.  
Today I altered one of my tables (users) with pt-online-schema-change  
One table(user\_comments) of my database had a foreign key (refer) to users table.  
I changed id column from int to bigint  
But at the end when it wanted to rename new table to original table, this message was displayed:

```auto
Error updating foreign key constraints: 2017-06-14T10:17:41 DBD::mysql::db do failed: Error on rename of './myblog/_users_new' to './myblog/users' (errno: 150 "Foreign key constraint is incorrectly formed") [for Statement "RENAME TABLE `myblog`.`_users_new` TO `myblog`.`users`"] at /usr/bin/pt-online-schema-change line 10700.

```

I know what is this, and I know firstly I must alter user\_comments table or remove Foreign key before alter users table, but I think pt-online-schema-change has bug because it should be kept up new table.  
It was full command:

```auto
pt-online-schema-change -uxxxx -pxxxx --max-load "Threads_running=400" --set-vars=foreign_key_checks=0 --alter-foreign-keys-method=auto --no-check-alter --critical-load="Threads_running=200" --alter="CHANGE COLUMN id id BIGINT UNSIGNED NOT NULL FIRST" D=myblog,t=users --execute

```

---

<div class="post-metadata">

**Author:** ![carlos.salguero](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/carlos.salguero/32/20_2.png) [@carlos.salguero](https://forums.percona.com/u/carlos.salguero)\
**Post date:** [June 14, 2017, 8:39am UTC](https://forums.percona.com/t/pt-online-schema-change-drop-the-old-and-new-table/5678/2 "2017-06-14T08:39:49Z")

</div>

You should use --alter-foreign-keys-method=rebuild\_constraints to tell pt-osc to do it automatically for you.

---

<div class="post-metadata">

**Author:** ![Hamoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/hamoon/32/1170_2.png) [@Hamoon](https://forums.percona.com/u/Hamoon)\
**Post date:** [June 24, 2017, 12:27am UTC](https://forums.percona.com/t/pt-online-schema-change-drop-the-old-and-new-table/5678/3 "2017-06-24T00:27:00Z")

</div>

Sorry Carlos But I think My question was not clear.  
I described completely in this Bug Report:  
[url][https://bugs.launchpad.net/percona-toolkit/+bug/1697915[/url]](https://bugs.launchpad.net/percona-toolkit/+bug/1697915%5B/url%5D)
