• Foreign keys are broken. The FOREIGN KEY statement does not start on a new line.

    There’s also a related problem. Since foreign keys have dependencies, it can happen (did to me) that the table referred to in the foreign key statement has not been created yet, in which case the SQL will fail. This is presumably why the PhpMyAdmin export puts all the keys at the end, after table creation.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author David Anderson / Team Updraft

    (@davidanderson)

    Hi wildmice,

    Yes…. in fact, after over 7 million downloads, you’re the first person to request the capability to handle foreign keys properly (a number of instances will just work by random happy chance. WP core does not use foreign keys, nor any particularly popular plugin AFAIK. UpdraftPlus has handled views, which are used in the popular Affiliate-WP plugin, for something like a couple of years). We would, though, like to add this. Can you post an example of your schema (no need to include the data, of course), to aid with our testing + development?

    David

    Plugin Author David Anderson / Team Updraft

    (@davidanderson)

    P.S. I’ve added an item to our task tracker for this.

    Thread Starter wildmice

    (@wildmice)

    Hi David. Here is the schema of the tables involved. Sorry, i don’t know which plugin these tables are for, as i’ve inherited a site with over 60 plugins and it’s not obvious from the table name.

    ~shanna
    =============================

    CREATE TABLE bRF8BR2o_crw_crosswords (
    project varchar(190) NOT NULL,
    name varchar(190) NOT NULL,
    crossword text NOT NULL,
    first_user bigint(20) unsigned NOT NULL,
    last_user bigint(20) unsigned NOT NULL,
    pending tinyint(1) NOT NULL DEFAULT ‘0’,
    PRIMARY KEY (project,name),
    CONSTRAINT bRF8BR2o_project_crossword FOREIGN KEY (project) REFERENCES bRF8BR2o_crw_projects (project) ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;

    CREATE TABLE bRF8BR2o_crw_editors (
    project varchar(190) NOT NULL,
    user_id bigint(20) unsigned NOT NULL,
    PRIMARY KEY (project,user_id),
    CONSTRAINT bRF8BR2o_project_editors FOREIGN KEY (project) REFERENCES bRF8BR2o_crw_projects (project) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;

    CREATE TABLE bRF8BR2o_crw_projects (
    project varchar(190) NOT NULL,
    default_level int(11) NOT NULL,
    maximum_level int(11) NOT NULL,
    used_level int(11) NOT NULL,
    PRIMARY KEY (project)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Foreign Keys broken’ is closed to new replies.