Title: Table not created
Last modified: November 2, 2017

---

# Table not created

 *  Resolved [kalligator](https://wordpress.org/support/users/kalligator/)
 * (@kalligator)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/)
 * I get an activation problem on my live server running PHP Version 5.6.26.
    The
   table does not get created.
 *     ```
       WordPress database error Invalid default value for 'created' for query CREATE TABLE wp_lightbox_photoswipe_img (
       	  imgkey char(64) DEFAULT '' NOT NULL,
       	  created datetime DEFAULT NOW(),
       	  width mediumint(7),
       	  height mediumint(7),
       	  PRIMARY KEY  (imgkey),
       	  INDEX (created)
       	) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci made by activate_plugin, do_action('activate_lightbox-photoswipe/lightbox-photoswipe.php'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, lightbox_photoswipe_activate, lightbox_photoswipe_create_tables, dbDelta
       ```
   
 * Even if I create it manually in PHPMyadmin when it comes to setting the default
   value for `created` to `CURRENT_TIMESTAMP` I get an error
 * > #1067 – Invalid default value for ‘created’
 * If I don’t set a defalut value it doesn’t work either.
 * On my local xampp with PHP Version 7.0.8 the plugin runs fine.
    -  This topic was modified 8 years, 7 months ago by [kalligator](https://wordpress.org/support/users/kalligator/).

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

 *  Plugin Author [Arno Welzel](https://wordpress.org/support/users/awelzel/)
 * (@awelzel)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/#post-9648282)
 * That’s indeed unexpected. I just pushed a new version which does not need default
   values for the “created” column.
 *  Plugin Author [Arno Welzel](https://wordpress.org/support/users/awelzel/)
 * (@awelzel)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/#post-9648294)
 * Well I forgot, that WordPress seems not to run the activation hook for the plugin
   when just updating – so another update will follow soon. But a complete fresh
   installation should work.
 *  Plugin Author [Arno Welzel](https://wordpress.org/support/users/awelzel/)
 * (@awelzel)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/#post-9648397)
 * I changed the database handling completely, so it should work now. Sorry for 
   the trouble.
 *  Thread Starter [kalligator](https://wordpress.org/support/users/kalligator/)
 * (@kalligator)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/#post-9649457)
 * Thanks so getting back with the fixes.
    There was still a problem with the table
   creation.
 * `WordPress database error Incorrect index name '' for query ALTER TABLE wp_lightbox_photoswipe_img
   ADD KEY '' ('created') from require('wp-blog-header.php'), require_once('wp-load.
   php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('
   plugins_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array,
   lightbox_photoswipe_init, lightbox_photoswipe_create_tables, dbDelta`
 * I turned lines 167 & 168 to:
 *     ```
       	  PRIMARY KEY imgkey (imgkey),
       	  INDEX created (created)
       ```
   
 * which stopped the errors.
 * However it was still not working. And as I found out, the culprit is that I am
   using a cdn for images, particularly jetpack’s photon!
    On sites on the same 
   server that I don’t use photon the plugin works great.
    -  This reply was modified 8 years, 7 months ago by [kalligator](https://wordpress.org/support/users/kalligator/).
    -  This reply was modified 8 years, 7 months ago by [kalligator](https://wordpress.org/support/users/kalligator/).
    -  This reply was modified 8 years, 7 months ago by [kalligator](https://wordpress.org/support/users/kalligator/).
 *  Plugin Author [Arno Welzel](https://wordpress.org/support/users/awelzel/)
 * (@awelzel)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/#post-9650389)
 * I finally sorted the problems out.
 * The problem is, that it MySQL and MariaDB don’t require a name for index columns(
   also see [https://dev.mysql.com/doc/refman/5.7/en/create-table.html](https://dev.mysql.com/doc/refman/5.7/en/create-table.html))
   but dbDelta() expects secondary index colums to be named when you call it with
   existing tables during an update. So the first activation works, but the update
   doesn’t.
 * The other problem is, that WordPress will not call the activation hook when updating
   an plugin in the backend – so I changed the complete database handling in that
   way that the table is created or updated (if required) during plugin initialisiation.
 * I also integrated the supposed workaround for images served by Jetpack Photon.
 *  Thread Starter [kalligator](https://wordpress.org/support/users/kalligator/)
 * (@kalligator)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/#post-9653202)
 * Thanks, everything is ok!

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

The topic ‘Table not created’ is closed to new replies.

 * ![](https://ps.w.org/lightbox-photoswipe/assets/icon-256x256.png?rev=2906302)
 * [Lightbox with PhotoSwipe](https://wordpress.org/plugins/lightbox-photoswipe/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/lightbox-photoswipe/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/lightbox-photoswipe/)
 * [Active Topics](https://wordpress.org/support/plugin/lightbox-photoswipe/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/lightbox-photoswipe/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/lightbox-photoswipe/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [kalligator](https://wordpress.org/support/users/kalligator/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/table-not-created/#post-9653202)
 * Status: resolved