0

I tried to run a specific migration table from the controller using the following code Artisan::call ("migrate:refresh --step=14"); but it does not refresh table 14, on the other hand it refreshes all the tables .. , any suggestion !!

Hamza DriouCh
  • 31
  • 1
  • 7

1 Answers1

0

That is the purpose of migrate:refresh. It rolls back the migrations and then runs them:

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

You may roll back and re-migrate a limited number of migrations by providing the step option to the refresh command. For example, the following command will roll back and re-migrate the last five migrations

If you want to run run a specific migration the command would be:

migrate --path=/database/migrations/my_migration.php

This does however not sound like the best way to achieve whatever you are trying to achieve. Without further information it's hard to suggest an alternative plan for how to achieve this.

Edit: If you are trying to insert pre-defined data into a table you should look into using Database Seeders which sound much more to be what you are looking for.

Alex Harris
  • 6,172
  • 2
  • 32
  • 57
  • Actually I have predefined data in the migration table.. if user delete all data by mistake !! and he ask for reset as a devlopper i just need to put [button reset all] with code that can refresh only the table desired – Hamza DriouCh Apr 22 '21 at 02:42
  • 1
    I have added some additional information for you in response to your comment. – Alex Harris Apr 22 '21 at 02:45
  • In depth .. now i don't need to refresh migration .. in other ways, i just need to run the seeder .. Well it works thanks to your suggestion – Hamza DriouCh Apr 22 '21 at 03:08