DDC-972: MySql MyISAM support #5508

Closed
doctrinebot opened this Issue Jan 7, 2011 · 7 comments

2 participants

@doctrinebot

Jira issue originally created by user nisnardi:

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.

@doctrinebot

Comment created by cedrictailly:

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"]) )
$table->addOption("engine",$class->table["engine"]);


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

/****

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.

@doctrinebot

Comment created by gabrielnn77:

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

@doctrinebot

Comment created by @beberlei:

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.

@doctrinebot

Comment created by stof:

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

@doctrinebot

Comment created by @beberlei:

Yes, that is probably what this ticket boils down to :-)

@doctrinebot

Comment created by @beberlei:

This was added in 2.2 or 2.3 with @Table(options={"engine":"MyISAM"})

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.2 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment