Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"php artisan migrate" shows "nothing to migrate"

I am new to laravel. I am working on laravel version 6. I have created migration. It works nicely the first time, but if i change something in the migration file and then i run php artisan migrate it shows nothing to migrate. I tried php artisan migrate --path as well but it does not work. To make it work i have to delete the migration file and create it again. I don't want to use php artisan migrate:fresh.

what should i do to run only one migrations file which has been changed?

like image 429
Akshay Rathod Avatar asked Oct 02 '19 14:10

Akshay Rathod


2 Answers

When you run php artisan migrate it'll check migration table if there is no new file in the migration folder it'll show you nothing to migrate.

If you want to rollback last migration.

To rollback the latest migration operation, you may use the rollback command. This command rolls back the last "batch" of migrations, which may include multiple migration files:

php artisan migrate:rollback

It'll delete the last created table.

The migrate:reset command will roll back all of your application's migrations:

php artisan migrate:reset

The migrate:fresh command will drop all tables.

php artisan migrate:fresh

php artisan migrate:fresh --seed

more info : document

like image 146
Dilip Hirapara Avatar answered Oct 09 '22 03:10

Dilip Hirapara


Sadly impossible. The best workaround is to use seeders and use php artisan db:seed after you use php artisan migrate:fresh. Why don't you want to use that?

like image 45
Norbert Jurga Avatar answered Oct 09 '22 04:10

Norbert Jurga