ゆずまの○○日記がシンプルでいいと思います!

プログラミングを中心に書いていこうと思ってます。

Laravel5.2 手動でマイグレーションファイルを削除をした後、マイグレーションができなくなった。

migrationファイルを作成する

[root@localhost blog]# php artisan make:migration create_tasks_table --create=tasks

上記のコマンドを実行すると、以下のファイルが作成される。 database/migrations/2019_07_24_081703_create_tasks_table.php

上記のファイルを手動で削除をしてしまった場合に、マイグレーションをしようとすると以下のエラーが出力される

[root@localhost blog]# php artisan make:migration create_tasks_table --create=tasks
  [ErrorException]
  include(/var/www/html/blog/vendor/composer/../../database/migrations/2019_07_24_081703_create_tasks_table.php): failed to open stream: No such file or directory

この場合に、

[root@localhost blog]# pwd
/var/www/html/blog
[root@localhost blog] composer dump-autoload -o

を実行すると、実行したいマイグレーションが実行できる

[root@localhost blog]# php artisan make:migration create_tasks_table --create=tasks
Created Migration: 2019_07_24_081748_create_tasks_table

参考

m2wasabi.hatenablog.com