Refresh laravel migration for specific table

Viewed 21372

Can I run php artisan migrate:refresh for specific table? Or can I refresh specific table migration in general?

I tried this:

php artisan migrate --path=/database/migrations/selected/

But it's not working!

3 Answers

You should add the path to your migration file to refresh just this table and run

php artisan migrate:refresh --path=/database/migrations/my_migration.php

if you need rollback:

php artisan migrate:rollback  --path=/database/migrations/my_migration.php

For Specific File run this command:

php artisan migrate:refresh --path="database\migrations\Your_Migration_File_Name_table.php"

Here --file= is for location of your file and migrate:refresh will empty your table data

If you want to empty all table's data from database then run

php artisan migrate:refresh command.

This works for me:

The --table and --create options may also be used to indicate the name of the table and whether the migration will be creating a new table. These options pre-fill the generated migration stub file with the specified table

php artisan make:migration create_users_table --create=users
php artisan make:migration add_votes_to_users_table --table=user

Source: https://laravel.com/docs/5.6/migrations

Related