Reputation: 35
I want to migrate:refresh a specific table called scores. I tried this:
php artisan migrate:refresh --path=/database/migrations/scores
but it says nothing to migrate.
Upvotes: 3
Views: 7843
Reputation: 11
Yes you can migrate:refresh selected migrations. You left off the .php extension from your line of code.
It should look like this example
php artisan migrate:refresh --path=/database/migrations/2020_09_28_224702_create_addresses_table.php
So, if scores is your migration file name, add .php
php artisan migrate:refresh --path=/database/migrations/scores
Upvotes: 1
Reputation: 10071
yes, you can do this by using Specify the path to the migrations.
Follow these steps:
first of all to create a migration, use the make:migration
command:
php artisan make:migration create_scores1_table
php artisan make:migration create_scores2_table
php artisan make:migration create_scores3_table
The new migration will be placed in your database/migrations directory. Each migration file name contains a timestamp like this:
2019_09_04_045427_create_scores1_table.php
2019_09_04_045500_create_scores2_table.php
2019_09_04_045518_create_scores3_table.php
Now, you want to refresh
a specific table(for example: scores2 table), so you can be used like this:
php artisan migrate:refresh --path=database/migrations/2019_09_04_045500_create_scores2_table.php
It only refresh the scores2 table and not all the rest of the table
Upvotes: 2
Reputation: 9161
You cannot refresh a single migration if its not the last one, but you can step
back in the migrations chain.
Assuming that you have five migrations and your table is at fourth place you can do like this:
php artisan migrate:refresh --step=2
With this command you refresh the last two migrations.
Note that each migration file name contains a timestamp which allows Laravel to determine the order of the migrations.
You can use the --path
argument but it should be a directory in wich the command searches for migrations not a single migration file.
If you run:
php artisan help migrate:refresh
You can see all the parameters accepted.
Upvotes: 2