开发者

Doctrine 2 migrations how to alter a table with a sqlite db?

开发者 https://www.devze.com 2023-01-14 05:26 出处:网络
I\'m having some issues with altering a table in the migr开发者_开发问答ations of doctrine 2. Following code always throws the error: Operation \'Doctrine\\DBAL\\Platforms\\AbstractPlatform::getAlterT

I'm having some issues with altering a table in the migr开发者_开发问答ations 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,
    ));
}


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.


There are a few niggling differences I've noticed between MySQL and SQLite when using an ORM. Using Doctrine, I found that foreign key relationships aren't maintained in SQLite like they are in MySQL.

This is a pain as I use SQLite in memory dbs for unit tests as I can't guarantee that persistence tests that pass in SQLite also pass in MySQL.

Actually, to get SQLite in memory dbs to work with Doctrine, I had to tweak the Doctrine SQLite driver (code at http://thecodeabode.blogspot.com/2010/12/dropping-sqlite-in-memory-databases-in.html) as the sql syntax generated for dropping a database fails for in memory dbs.

0

精彩评论

暂无评论...
验证码 换一张
取 消