[DDC-972] MySql MyISAM support Created: 07/Jan/11  Updated: 15/Sep/13  Resolved: 11/Sep/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.0
Fix Version/s: 2.2
Security Level: All

Type: Improvement Priority: Major
Reporter: nicolas isnardi Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 2
Labels: None



We can not set MySql Engine for MyISAM. MySqlPlatform has a _getCreateTableSQL where you can pass some options with the engine param.
Not able to set it up from yml, xml or annotation schema.

Comment by C├ędric Tailly [ 19/May/11 ]

I have the same problem and I didn't find documentation to select the engine for a given table.

I tried to understand the code by myself and made modifications of my Doctrine v2.0.5, perhaps this is not the best one but here is a beginning of a solution :


@ ORM\Mapping\Driver\DoctrineAnnotations.php:100

final class Table extends Annotation

{ public $name; public $schema; public $indexes; public $uniqueConstraints; public $engine; }

@ ORM\Mapping\Driver\AnnotationDriver.php:144

$primaryTable = array(
'name' => $tableAnnot->name,
'schema' => $tableAnnot->schema,
'engine' => $tableAnnot->engine

@ ORM\Tools\SchemaTool.php:133

$table = $schema->createTable($class->getQuotedTableName($this->_platform));

if ( isset($class->table["engine"]) )


...and to define for instance the MyISAM engine in annotations :


  • @Entity
  • @Table(engine="MyISAM")

Because there is no foreign key on MyISAM tables, there are still problems on the schema creation/update when Doctrine executes the corresponding "alter table" SQL commands.

Comment by gabriel sancho [ 12/Jul/12 ]

in Doctrine 2.2.2 will be

Doctrine/ORM/Tools/SchemaTool.php-149- /// PATCH ------------------------------------
Doctrine/ORM/Tools/SchemaTool.php-150- if ( isset($class->table["engine"]) )
Doctrine/ORM/Tools/SchemaTool.php-151- $table->addOption("engine",$class->table["engine"]);
Doctrine/ORM/Tools/SchemaTool.php-152- /// PATCH ------------------------------------

Doctrine/ORM/Mapping/ClassMetadataInfo.php-1719- /// PATCH ------------------------------------
Doctrine/ORM/Mapping/ClassMetadataInfo.php-1720- if (isset($table['engine']))

{ Doctrine/ORM/Mapping/ClassMetadataInfo.php-1721- $this->table['engine'] = $table['engine']; Doctrine/ORM/Mapping/ClassMetadataInfo.php-1722- }

Doctrine/ORM/Mapping/ClassMetadataInfo.php-1723- /// PATCH ------------------------------------

Doctrine/ORM/Mapping/Table.php-42- /// PATCH ------------------------------------
Doctrine/ORM/Mapping/Table.php-43- /** @var string */
Doctrine/ORM/Mapping/Table.php-44- public $engine;
Doctrine/ORM/Mapping/Table.php-45- /// PATCH ------------------------------------

Doctrine/ORM/Mapping/Driver/AnnotationDriver.php-181- /// PATCH ------------------------------------
Doctrine/ORM/Mapping/Driver/AnnotationDriver.php-182- $primaryTable['engine'] = $tableAnnot->engine;
Doctrine/ORM/Mapping/Driver/AnnotationDriver.php-183- /// PATCH ------------------------------------

i found a problem in ManyToMany relations, the intermediate table will be InnoDB

Comment by Benjamin Eberlei [ 13/Jul/12 ]

You can do all tables as MyISAM already through metadata using @Table(options=

{"engine": "MyISAM"}

) except Many-To-Many Join Tables. But you could create a listener to the "postSchemaGenerate" event and accept the schema instance there, modify everything accordingly.

Comment by Christophe Coevoet [ 13/Jul/12 ]

should we add the support of the options for the @JoinTable annotation ?

Comment by Benjamin Eberlei [ 13/Jul/12 ]

Yes, that is probably what this ticket boils down to

Comment by Benjamin Eberlei [ 11/Sep/13 ]

This was added in 2.2 or 2.3 with

Generated at Sun Oct 04 21:30:55 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.