Can I explicitly specify ENGINE=InnoDB in WordPress?

I converted all my tables to InnoDB, but the MySQL server (which I can’t access, as I’m on shared hosting) has MyISAM as the default, so every new table that WordPress creates (e.g. when I add a new site on my multisite) uses the MyISAM engine and I have to alter it manually. Can I somehow set WordPress up to enforce the InnoDB engine when creating new tables?

I know that by default WordPress doesn’t specify anything and lets the table use the default engine, but I’m wondering if there is some plugin where I could add the

Read More
ENGINE=InnoDB

clause to all the CREATE TABLE queries.

Related posts

1 comment

  1. If the code creating new tables uses dbDelta() (it should), you can filter the query (see wp-admin/includes/upgrade.php):

    add_filter( 'dbdelta_create_queries', function( Array $queries )
    {
        foreach ( $queries as $table => $query )
        {
            if ( FALSE !== stripos( $query, 'CREATE TABLE' ) )
            {
                // change the query here
            }
        }
    
        return $queries;
    });
    

Comments are closed.