我在使用Symfony2和Doctrine在非默認數據庫上執行數據庫遷移時遇到了一些麻煩。Doctrine2在多個數據庫上遷移Symfony2
我有兩個dbs和兩個實體管理器,我正在使用。我有兩個捆綁包,每個捆綁適用於各自的EM,因此一切都應該相當分離。
在我的DefaultBundle下我有大約20個遷移文件的遷移,這些遷移文件都適用於默認數據庫。我的SecondBundle有一個適用於seconddb的遷移文件。
當我嘗試運行
php app/console doctrine:migrations:migrate --no-interaction --em="second"
我越來越
Migration 20140709212101 failed during Execution. Error There is no table with name 'second_database.users' in the schema.
[Doctrine\DBAL\Schema\SchemaException]
There is no table with name 'second_database.users' in the schema.
這完全是真實的,「用戶」是我的主數據庫的表。這裏發生的事情是,它試圖運行的遷移文件實際上是DefaultCore中的第一個20(它們都是舊的並且已經被應用)。因爲我已經指定--em它正在跨越遷移我想不想與我正在使用的db一起運行。似乎沒有另一個命令行選項來指定一個類似於其他遷移命令(如generate)的包。我想忽略DefaultBundle,只需從我的SecondBundle運行我的遷移。
這看起來不像支持,但有希望(https://github.com/doctrine/DoctrineMigrationsBundle/pull/46)。你應該嘗試pvanlieflands叉子 – greg0ire 2014-10-11 17:30:29