Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh laravel migration for specific table

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!

like image 584
CairoCoder Avatar asked Nov 08 '17 01:11

CairoCoder


People also ask

How do I move a table again in Laravel?

IF you want to re-migrate all the database, you can simply do: php artisan migrate:refresh . IF you want to make sure your database to be clean with your latest changes, you can drop your entire database tables and do php artisan migrate again. Also, you can try php artisan migrate --seed if you have any seeder.

What is difference between migrate fresh and refresh in Laravel?

php artisan migrate:fresh is used when we want a fresh or new installation of our database. It deletes all the existing tables of the database and runs the migrate command. php artisan migrate:refresh is a two in one command that executes the :rollback command and the migrate command.

What is migrate refresh?

The migrate:refresh command is used to rollback all the migrations and then re-run the migrations. Basically, it is used to re-create the entire database.


2 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
like image 60
Yoss Avatar answered Nov 06 '22 20:11

Yoss


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.
like image 2
Tuhin Avatar answered Nov 06 '22 20:11

Tuhin