0

We recently altered our EE tables to use InnoDB as the database engine instead of MyISAM. All is good. INNODB is also set as the default engine in MySQL's preferences.

I just noticed that when Expression Engine is creating new tables (such as when we just installed CE Image) they are still being created as MyISAM.

This appears to be set in the following CI file:

/system/codeigniter/system/database/drivers/mysql_forge.php where I find this:

/**
 * The default engine to use when creating new tables.
 */
const ENGINE_DEFAULT = 'MyISAM';

I'd prefer not to hack the codeigniter core files. Is there a way I can override this value in EE's config file?

I am currently on 2.8.1 and getting ready to update to 2.10.1

1

Short version, No you can't alter this setting via a config file.

Long version, you see in your snippet in the OP it is defined as a const constant on the Class, conversly the items you change via the config files are variables. You can't change or redefine contastants with code as by their nature they are fixed.

Now it is possible (if you look to the _create_table function in this file) that the CI DB Forge object could pass a different engine (note the 6th parameter , $engine=self::ENGINE_DEFAULT) however if we look at /system/codeigniter/system/database/DB_forge.php (the parent class on which the driver specific classes inherit), line 193 (EE 2.10.0) we see the only call to _create_table :

$sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);

Note that there is no 6th paramter, ergo the base CI database system is not and can not accept a configuration value, even if we could add such a value in we couldn't pass it to the relivent function without altering the core files.

So in this case I'm afraid the only solution is to alter the const on file as you say, and carefully monitor your core upgrade to ensure they don't change this file.

As a little bonus I've looked through the update files up to 2.10.0 and I don't see any changes at this level. I dob note however that the EE_Schema does define the engine as MyISAM however I beleive this is only relivent to a fresh installation. Therefor I'd say change your value, perform your upgrade and check that no tables have been created as MyISAM and that your changed const remains in the file...

| improve this answer | |
  • 1
    Note that CE Image isn't installed and doesn't have any databases or table references at all. Also a third-party add-on doesn't utilise the settings in the DB Forge object. In all the add-ons I've created I specify InnoDB in the table creation, the create table is run via SQL command which would be processed directly not interpretted by EE. So what you describe is surely only for first-party add-ons (forum, msm) and core (initial installation)? – Peter Lewis May 30 '15 at 7:52
  • HI Peter, very good point. I was indeed only speaking from the 1st party perspective, What I describe above is only relivent for modules/libraries that use the standard create_table call in EE's `db1 class. Watch out for those pesky 3rd party add ons as they may forge their own path! :D – Blatant Jun 1 '15 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.