Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
rollback specific migration in laravel

How to rollback specific migration in laravel ?

Aman Jain, March 6, 2022February 8, 2024

In this article we will learn rollback specific migration in laravel, in our recent article i wrote about creating migration in laravel and sometimes after creating migration we want to rollback specific migration laravel so in this article i will show you to rollback a specific migration in laravel. Laravel artisan have multiple options to rollback the migration like we can rollback all migrations, we can rollback last n number of migration using step option and in the same way we can rollback all specific rollback using reset option.

Rollback specific migration in laravel

In relational databases rollback is a technique to revert back the database operation in previous state. In the same way laravel maintains it migrations in file and database, and we can rollback the operation to its previous state using artisan command.

However there is no direct command to rollback the specific migration but we can use this blow tricks to rollback the migration.

Steps to rollback specific migration

Step 1 : Open database and check migrations table

In this step we will open our database using any tool like phpMyAdmin or command line then check migrations table.

Screenshot 2022 03 06 at 8.17.43 PM
Migration table

As you can see we have migration table and i want to rollback 2022_02_15_174050_add_status_movies_table

Step 2 : Change batch number to last number

Now, change the batch number of 2022_02_15_174050_add_status_movies_table to last number of batch number , In our example last number is 8 so change the 2022_02_15_174050_add_status_movies_table batch to 9

92022_02_15_174050_add_status_movies_table9
Change batch number

Step 3 : Run artisan rollback command

Run the artisan command rollback to make the changes

php artisan migrate:rollback --step=1

So here we are rollback the last batch which is 9

Rolling back: 2022_02_15_174050_add_status_movies_table


Rollback last migrations using step option

We can also rollback last migration using the step option in artisan command, step option accept numeric parameter to rollback last migrations. For example if --step =2 then it means it will rollback last two migrations.

here is the command

php artisan migrate:rollback --step=3

Rollback last batch migrations

We can also rollback last batch of migration using the migration rollback command without any options as below

Here is the command

php artisan migrate:rollback

Rollback all migrations and reset database

We can also rollback all migration and also can reset the database migration to start point using artisan migration:reset command

Here is the command

php artisan migrate:reset

Rollback all and Re run all migrations

refresh option is used to rollback all migration and it runs again migration command to re create the database

Here is the command

php artisan migrate:refresh

Related

Uncategorized laravelmigrationrollback

Post navigation

Previous post
Next post

Related Posts

Uncategorized confirm password validation in Laravel

Password and confirm password validation in Laravel

January 26, 2022November 10, 2023

There is many ways to check the password and confirm password validation in laravel. we can match password using the equals to operator but in that case we need to work as core PHP. So In laravel we have Validation library to create the validation rules. Laravel itself provides multiple…

Read More
Uncategorized Laravel ajax form with example

Submit form using jQuery in Laravel

November 18, 2021November 18, 2021

jQuery is most popular library to handle the client side events like form submit, click, change etc. In this article we will learn to submit the form using jQuery Ajax method. Ajax is mostly used when we do not want to reload the page and real time interaction. In this…

Read More

Quickly add Google translate widget button to any website

January 10, 2022November 12, 2023

Google translator is most popular translation engine to translate any word into any language. Translation of complete website can be a hectic task to developer but using the Google translation we can easily translate complete website into any language. By adding the Google translate widget to website it increase the…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • Understanding High Vulnerabilities: A Closer Look at the Week of July 14, 2025
  • Exploring Fresh Resources for Web Designers and Developers
  • The Intersection of Security and Technology: Understanding Vulnerabilities
  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
  • Understanding High Vulnerabilities: A Deep Dive into the Weekly Summary
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version