English 中文(简体)
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 DoctrineDBALPlatformsAbstractPlatform::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.





相关问题
Copy data from Access to SQL

I am in the process of migrating an existing Access database to a SQL database with a web front-end. I have successfully copied the database to SQL using the SQL Server Migration tool and am working ...

MongoMapper and migrations

I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...

Switching to WPF. Is it time?

I m considering switching from MFC to WPF. My first concern is that there are too many users who don t have .NET with WPF installed yet. Can anybody point to a source containing the WPF penetration ...

rake db:migrate running all migrations correctly

I m fairly new to Ruby on Rails here. I have 2 migrate files that were provided. The first one, prefixed with 001, creates a table and some columns for that table. The next migrate file, prefixed ...

Migrate Java Applet to what/where?

I am reviewing currently a medium size code base (around 30K LOC) which uses a huge Applet and interfaces with other systems. It s a tool to create custom labels, so we need drag-n-drop and other ...

热门标签