I have table with foreign key reference and i recently changed the create table query with ON DELETE CASCADE

$wpdb->query("DROP TABLE IF EXISTS $table_name2");  
    //CREATE TABLE bmg_CompanyCategoryCross
        $sql = "CREATE TABLE IF NOT EXISTS $table_name2 (
        id mediumint(9) NOT NULL AUTO_INCREMENT,
        companyid mediumint(9) NOT NULL,
        categoryid mediumint(9) NOT NULL,       
        PRIMARY KEY  (id),
        FOREIGN KEY  (companyid) REFERENCES $table_name(id) ON DELETE CASCADE,
        FOREIGN KEY  (categoryid) REFERENCES $table_name3(id)
    ) $charset_collate;";

This table is creating on my local machine but not on live server. Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.