How to Rollback Migration in Laravel?
This example is focused on how to rollback migration in laravel. i would like to share with you how to revert migration in laravel. I’m going to show you about laravel migration rollback example. you can understand a concept of laravel migration rollback step 1.
i will simple example of how to rollback database migration using laravel migrate command. you can also migrate specific migration using step argument, also you can migrate rollback all migrations. let's see very simple examples how migration rollback is working.
you can use this commands with laravel 6, laravel 7, laravel 8 and laravel 9 version.
Created New Migrations:
php artisan make:migration create_posts_table
php artisan make:migration create_items_table
php artisan make:migration create_products_table
Rollback Last Migration:
php artisan migrate:rollback
Rollback Last Migrations using Step:
you can pass --step option with rollback number of migration from last. here it will rollback last two migration.
php artisan migrate:rollback --step=2
Rollback All Migrations:
rollback all means it will reset all migration. so if you change anything on migration file then it will recreate and affect it.
php artisan migrate:reset
i hope it can help you...
We are Recommending you
- How to add Default Value of Column in Laravel Migration?
- Laravel Migration Custom Index Name Example
- Laravel Migration Custom Foreign Key Name Example
- How to Add Index in Laravel Migration?
- How to Add Foreign Key in Laravel Migration?
- Laravel Migration - How to Add New Column in Existing Table ?
- How to Change Table Name using Laravel Migration?
- How to Remove Column from Table in Laravel Migration?
- How to Change Column Name and Data Type in Laravel Migration?
- How to Create Table using Migration in Laravel?
- Laravel - How to remove foreign key constraint using migration?