Tuesday, 27 April 2021

Laravel Roll Back & Migrate Using A Single Command

 https://laravel.com/docs/5.7/migrations#roll-back-migrate-using-a-single-command

NOTE: PHP artisan migrate command is based on list of entries in migrations table in database.

If it is empty(I.E you have removed all records in DB, the following has no effect)

Rollback & Migrate In Single Command

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:

php artisan migrate:refresh

// Refresh the database and run all database seeds...
php artisan migrate:refresh --seed

Rolling Back Migrations

To rollback the latest migration operation, you may use the rollback command. This command rolls back the last "batch" of migrations, which may include multiple migration files:

php artisan migrate:rollback

You may rollback a limited number of migrations by providing the step option to the rollback command. For example, the following command will rollback the last five migrations:

php artisan migrate:rollback --step=5

No comments:

Post a Comment