In this article, we will see how to roll back specific migrations in laravel. We will learn how to last migration revert/revoke in laravel 6, laravel 7, laravel 8, and laravel 9. Also, you can roll back all migration in laravel using the command line. So, we will explain how to roll back database migration using the laravel migration command.
Laravel migrations are like version control for your database, allowing your team to define and share the application's database schema definition.
So, let's see rollback specific migration laravel 6/7/8/9, how to delete the last migration file in laravel, and roll back all migrations laravel.
Using the rollback artisan command will roll back the latest migration. This command roll back the last "batch" of migrations. It includes multiple migrations files.
php artisan migrate:rollback
Using the --step artisan command will roll back the limited number of migration steps to roll back migrations.
php artisan migrate:rollback --step=3
The above command will roll back the last three migrations.
Using the reset artisan command will roll back all migrations.
php artisan migrate:reset
Using the --path artisan command will create or remove migrations for custom path locations. --path command required full path of file location.
php artisan migrate:rollback --path=/database/migrations/your-specific-migration-file-name.php
php artisan migrate:rollback --path=/database/migrations/2014_10_12_000000_create_users_table.php
Using the refresh artisan command will roll back all migrations and re-creates the entire database.
php artisan migrate:refresh
Also, you can roll back and re-migrate a limited number of migrations with the help of the step option with the refresh command.
php artisan migrate:refresh --step=3
Using the fresh artisan command will drop all database tables and then create new fresh migrations.
php artisan migrate:fresh
You might also like:
In this tutorial, we will see laravel 8 ajax crud with yajra datatable. I will show you how to create ajax crud ope...
Jan-05-2022
Hello Friends, In this tutorial we will learn how to send email using node.js app. In this tutorial we will see send...
Jul-28-2021
In this article, we will see how to create a multi-language website in laravel. In this example, you can understand...
Nov-09-2020
In this article, we will see the laravel 8 autocomplete search from the database. Using ajax autocomplete...
Mar-01-2021