Laravel 5.1 refresh and seed a single table

V4n1ll4 picture V4n1ll4 · Nov 4, 2015 · Viewed 23.5k times · Source

I'm looking to refresh and seed a single table in Laravel 5.1. Is this even possible?

I have tried the below, but it gives an error (incorrect syntax).

php artisan migrate:refresh --path=database/migrations/CreateTableTimesheet

If I use: php artisan migrate:refresh it just says:

Nothing to migrate

Answer

Zakaria Acharki picture Zakaria Acharki · Nov 4, 2015

You could use migrate:refresh command that will roll back all of your migrations and then execute the migrate command. This command effectively re-creates your entire database :

php artisan migrate:refresh

And you may use the --class option to specify a specific seeder class to run individually :

php artisan db:seed --class=UserTableSeeder

The full code will be :

php artisan migrate:refresh
php artisan db:seed --class=UserTableSeeder

Hope this helps.