简体   繁体   English

Doctrine 2迁移如何使用sqlite db更改表?

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

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 . 我在教义2的迁移中更改表时遇到一些问题。以下代码始终会引发错误: 平台不支持操作'Doctrine \\ DBAL \\ Platforms \\ AbstractPlatform :: getAlterTableSQL'

This is strange as alter table is supported by sqlite. 这很奇怪,因为sqlite支持alter table。

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

即使Sqlite“支持” ALTER TABLE,与大多数其他数据库( http://www.sqlite.org/lang_altertable.html )相比,允许的操作集还是很少的,因此,为什么它被认为不受教义的支持DBAL。

There are a few niggling differences I've noticed between MySQL and SQLite when using an ORM. 使用ORM时,我发现MySQL和SQLite之间有一些细微的区别。 Using Doctrine, I found that foreign key relationships aren't maintained in SQLite like they are in MySQL. 使用Doctrine,我发现在SQLite中没有像在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. 这很痛苦,因为我无法在内存dbs中使用SQLite进行单元测试,因为我不能保证通过SQLite的持久性测试也可以通过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. 实际上,要使内存数据库中的SQLite与Doctrine一起使用,我必须调整Doctrine SQLite驱动程序(代码位于http://thecodeabode.blogspot.com/2010/12/dropping-sqlite-in-memory-databases-in。 html ),因为为删除数据库而生成的sql语法在内存dbs中失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM