Title: Table re-create doesn&#8217;t work as expected
Last modified: December 25, 2021

---

# Table re-create doesn’t work as expected

 *  Resolved [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/table-re-create-doesnt-work-as-expected/)
 * Hey,
    I am using the latest version 3.2.1
 * So I installed the plugin and `wp_tm_tasks` and `wp_tm_taskmeta` table get created
   after install and activate.
    then I go to my database and deleted both tables.
   then tried to run some of the optimizations, and I got errors in the log that`
   wp_tm_tasks table doesn’t exist as expected.
 * then deactivate the plugin and reactivate It again, but tables don’t get created
   again. I looked into the code and found `reinstall_in_needed` is the only function
   that helps in DB table create but it’s not being called on the plugin activation
   hook.
 * In general, if the table is missing then after deactivate/activate they should
   get back again. but here it’s not happening.
 * Another issue that I found while I was trying to convert the DB engine to InnoDB.
   in the backend UI it shows success, but when I debugged in the network tab in
   developer tools, I see the error that the table doesn’t exist.
 * So if there is an error it should an error in UI instead of showing it a success.
   
   And why it’s not working on the Plesk server? any idea?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Harshad](https://wordpress.org/support/users/bornforphp/)
 * (@bornforphp)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/table-re-create-doesnt-work-as-expected/#post-15195482)
 * [@vijayhardaha](https://wordpress.org/support/users/vijayhardaha/) I’ll check
   this with our development team and update you soon.
 * Thank you for your time and patience.
 *  [Harshad](https://wordpress.org/support/users/bornforphp/)
 * (@bornforphp)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/table-re-create-doesnt-work-as-expected/#post-15197599)
 * > Another issue that I found while I was trying to convert the DB engine to InnoDB.
   > in the backend UI it shows success, but when I debugged in the network tab 
   > in developer tools, I see the error that the table doesn’t exist.
   > So if there is an error it should an error in UI instead of showing it a success.
   > 
   > And why it’s not working on the Plesk server? any idea?
   > > Could you please explain to us the steps to reproduce the issue?
    -  This reply was modified 4 years, 7 months ago by [Harshad](https://wordpress.org/support/users/bornforphp/).
    -  This reply was modified 4 years, 7 months ago by [Harshad](https://wordpress.org/support/users/bornforphp/).
 *  Thread Starter [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/table-re-create-doesnt-work-as-expected/#post-15197977)
 * I have got that error in the Plesk server due to the “Table doesn’t exist” error,
   although my table exists. So I am not sure why it gives me an error “Table doesn’t
   exist”
 * > So if there is an error it should an error in UI instead of showing it a success.
 * For this UI issue follow these steps
 * 1. Create a custom db table wp_test manually in your test website.
    2. Make sure
   wp_test has **MyISAM** DB Engine not InnoDB 3. Then Install & activate the WP-
   Optimize plugin and goto database > tables 4. You’ll see wp_test in your list
   and then the convert to InnoDB button will be there. 5. Now manually delete the
   wp_test DB table(NOTE: don’t refresh the tables list in the plugin backend UI)
   6. Now come to the UI page and click the “Convert to InnoDB” button.
 * So now our table doesn’t exist, so there should be an error when we click on “
   Convert to InnoDB” but when you’ll click on “Convert to InnoDB” after manually
   deleting wp_test table, You’ll still see a success message. It doesn’t tell that
   you have an error.
 * Even though an error is logged in response but status success status is always
   true.
 *  Thread Starter [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/table-re-create-doesnt-work-as-expected/#post-15198116)
 * Alright, I spent time debugging the “Table doesn’t exist” issue and found why
   this is happening.
 * > Note: The problem wasn’t related to the Plesk server.
 * The problem is happening due to Case sensitive table names. My WP Prefix has 
   some uppercase letters with lower case letters and if you’ll review your plugin
   code on
 * File : `optimizations/orphanedtables.php`
    Function: `private function convert_table(
   $table_obj)` Line: `$table_name = sanitize_key($table_obj->Name);`
 * You’ll see `sanitize_key` change the letter case of table name and then the `
   ALTER` query returns “Table doesn’t exist”
    `sanitize_key` is not necessary there,
   you’re getting table name from the Information object so you don’t really need
   to convert that information. it will return the correct value from DB information.
 *  [Harshad](https://wordpress.org/support/users/bornforphp/)
 * (@bornforphp)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/table-re-create-doesnt-work-as-expected/#post-15199783)
 * [@vijayhardaha](https://wordpress.org/support/users/vijayhardaha/) Thanks for
   sharing the information, I’ll share the same with our development team, hopefully
   it should be fixed in next release

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Table re-create doesn’t work as expected’ is closed to new replies.

 * ![](https://ps.w.org/wp-optimize/assets/icon-256x256.png?rev=1552899)
 * [WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance](https://wordpress.org/plugins/wp-optimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-optimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-optimize/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-optimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-optimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-optimize/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Harshad](https://wordpress.org/support/users/bornforphp/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/table-re-create-doesnt-work-as-expected/#post-15199783)
 * Status: resolved