php-laravelHow do I roll back a Laravel migration using PHP?
You can roll back a Laravel migration using PHP by using the artisan
command. artisan
is the command-line interface included with Laravel.
To roll back a migration, you can use the migrate:rollback
command. This command will roll back the last "batch" of migrations, which may include multiple migration files.
Example
php artisan migrate:rollback
Output example
Rolled back: 2019_08_19_000000_create_failed_jobs_table
This command will roll back the last batch of migrations, which may include multiple migration files. You can also specify a specific migration to roll back by using the --step
option.
Example
php artisan migrate:rollback --step=2
This command will roll back the last two migrations.
You can also roll back all of your migrations by using the migrate:reset
command.
Example
php artisan migrate:reset
This command will roll back all of your migrations.
Code explanation
artisan
- command-line interface included with Laravelmigrate:rollback
- command to roll back the last "batch" of migrations--step
- option to specify a specific migration to roll backmigrate:reset
- command to roll back all of your migrations
Helpful links
More of Php Laravel
- How can I use the Laravel WhereIn method in PHP?
- How can I convert JSON data to XML using PHP Laravel?
- How can I use PHP, Laravel, and Vue together to create a web application?
- How can I create a website using the Laravel PHP framework and a template?
- How do I set up a Laravel worker using PHP?
- How can I find a vacancy for a PHP Laravel developer?
- How do I use Laravel validation in PHP?
- How can I use Laravel Sail to develop a web application with PHP?
- How do I update a model using PHP Laravel?
- How can I find a job using PHP and Laravel?
See more codes...