LoginSignup
3
3

More than 3 years have passed since last update.

Symfony4のdoctrineでmake:migrationしても変更を検知しない場合

Last updated at Posted at 2019-11-23

はじめに

symfony4.4のdoctrineの説明をみながらマイグレーションを操作した。

Migrations & Adding more Fieldsで追加したdescriptionカラムの変更を、doctrineは検知をせず、以下のように無情な回答。

php bin/console make:migration

 [WARNING] No database changes were detected.

操作した内容をどこかに記録していると予想していたけど、調査したら、var配下のCacheに保存をしている模様。

以下のようにキャッシュをクリアしたら。。。

php bin/console doctrine:cache:clear-metadata

 // Clearing all Metadata cache entries


 [OK] Successfully deleted cache entries.

正常にマイグレーション用のファイルを作成しました!!

php bin/console make:migration

  Success! 

 Next: Review the new migration "src/Migrations/Version20191123063407.php"
 Then: Run the migration with php bin/console doctrine:migrations:migrate
 See https://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html

おまけ

参考文献にある、以下のコマンドを実行したら、強制的にDBにカラムが追加をされていました。

php bin/console doctrine:schema:update --force

 Updating database schema...

     1 query was executed

こちらはEntityからSQLを作成して、即実行をするコマンドでした。

php bin/console doctrine:schema:update --help 
・・・
  Alternatively, you can execute the generated queries:
  doctrine:schema:update --force

参考文献

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3