• Resolved Chris Lloyd

    (@chrisl27)


    Hi,

    I’ve upgraded to SlimStat 3.5.6, and have an issue with newly created multisite sites and the generation of the wp_X_slim_stats table with the new foreign key constraints.

    WP reports:

    [Fri Mar 14 15:34:59 2014] [error] [client 127.0.0.1] WordPress database error Cannot add foreign key constraint for query CREATE TABLE IF NOT EXISTS wp_3_slim_outbound (\r\n\t\t\t\toutbound_id INT UNSIGNED NOT NULL auto_increment,\r\n\t\t\t\toutbound_domain VARCHAR(255) DEFAULT '',\r\n\t\t\t\toutbound_resource VARCHAR(2048) DEFAULT '',\r\n\t\t\t\ttype TINYINT UNSIGNED DEFAULT 0,\r\n\t\t\t\tnotes VARCHAR(512) DEFAULT '',\r\n\t\t\t\tposition VARCHAR(32) DEFAULT '',\r\n\t\t\t\tid INT UNSIGNED NOT NULL DEFAULT 0,\r\n\t\t\t\tdt INT(10) UNSIGNED DEFAULT 0,\r\n\t\t\t\tPRIMARY KEY (outbound_id),\r\n\t\t\t\tFOREIGN KEY fk_id (id) REFERENCES wp_3_slim_stats(id) ON UPDATE CASCADE ON DELETE CASCADE,\r\n\t\t\t\tINDEX odt_idx(dt)\r\n\t\t\t) COLLATE utf8_general_ci made by do_action('wp_ajax_slimtrack_js'), call_user_func_array, wp_slimstat::slimtrack_js, wp_slimstat::slimtrack, wp_slimstat_admin::init_environment, wp_slimstat_admin::init_tables, wp_slimstat_admin::_create_table, referer: https://test.macbook.example.com/

    The particular failed constraint is:
    FOREIGN KEY fk_browser_id (browser_id) REFERENCES wp_slim_browsers(browser_id)

    My installation lists wp_slim_stats:
    browser_id smallint(5) unsigned NO 0

    and wp_slim_browsers:
    browser_id mediumint(8) unsigned NO PRI NULL auto_increment

    Creating this table with the constraint fails as the two columns have different types. Changing the create statement for that field to: “browser_id MEDIUMINT UNSIGNED NOT NULL DEFAULT 0” (i.e. MEDIUMINT instead of SMALLINT) solves the issue.

    The default creation SQL for wp_slim_browsers appears to use SMALLINT, so I guess it changed from MEDIUMINT to SMALLINT sometime in the past, but it hasn’t been a problem since there weren’t FKs before? Is there a safe method to resolve this issue?

    Many thanks,

    – Chris

    https://www.ads-software.com/plugins/wp-slimstat/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jason Crouse

    (@coolmann)

    We introduced foreign keys in version 3.5.6 (see changelog). We will make sure to consolidate types in version 3.5.7. Thank you for pointing this out!

    Thread Starter Chris Lloyd

    (@chrisl27)

    Yep, I noticed that in the changelog so I knew right where to look ??

    Issuing:

    ALTER TABLE wp_slim_browsers CHANGE browser_id browser_id SMALLINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;

    fixed it up no problem.

    Plugin Author Jason Crouse

    (@coolmann)

    Yep. That’s what I’m gonna add to 3.5.7 ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multisite SQL errors creating wp_X_slim_stats tables (3.5.6)’ is closed to new replies.