Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.1 refresh and seed a single table

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

like image 235
V4n1ll4 Avatar asked Nov 04 '15 10:11

V4n1ll4


People also ask

How do you seed one seeder in Laravel?

Writing SeedersA seeder class only contains one method by default: run . This method is called when the db:seed Artisan command is executed. Within the run method, you may insert data into your database however you wish. You may use the query builder to manually insert data or you may use Eloquent model factories.


1 Answers

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.

like image 102
Zakaria Acharki Avatar answered Sep 21 '22 15:09

Zakaria Acharki