views:

32

answers:

1

I'm having some issues with altering a table in the migrations of doctrine 2. Following code always throws the error: Operation 'Doctrine\DBAL\Platforms\AbstractPlatform::getAlterTableSQL' is not supported by platform.

This is strange as alter table is supported by sqlite.

public function up(Schema $schema)
{
    $user = $schema->getTable('user');
    $user->addColumn('resellerId', 'integer', array(
        'length'        => '10',
        'notnull'       => true,
        'unsigned'      => true,
    ));
}
+1  A: 

Even though ALTER TABLE is "supported" by Sqlite, the set of allowed operations is minimal compared to most other databases (http://www.sqlite.org/lang_altertable.html), hence why it is considered as not supported by the Doctrine DBAL.

I also did test this on a mysql database and their it works perfectly.
Skelton
So? This does not change my statement. Mysql != Sqlite. Please read my answer carefully.
I did read your answer carefully, But I thought that the Doctrine DBAL unifies all sql to work on a set of databases like MySQL SQLite, MSSQL, Oracle, ... Or I'm a so wrong?
Skelton
It is unified as far as it is possible without too much effort. Portability between many different RDBMS is much more difficult than it sounds. Like I said, SQLite has only very limited ALTER TABLE support, so limited that the Doctrine DBAL considers it as not supported. It makes no sense to support it if all you can do as add columns or rename the table...