문제

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,
    ));
}
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top