How to delete Laravel migration

Learn how to delete Laravel migration with an example: an easy step-by-step guide.

Deleting a Laravel Migration

Migrations are a great way to keep track of changes to your database schema. With migrations, you can easily undo changes and create multiple versions of the same database. In some cases, you may need to delete a migration in Laravel. This can be done using the migrate:rollback command.

To delete a migration, you first need to identify the migration file you want to delete. You can find this in the database/migrations directory. Once you have identified the file, you can run the following command from the command line:


php artisan migrate:rollback --step=1

The --step=1 flag tells Laravel to rollback the last migration. If you want to rollback multiple migrations, you can use the --step flag with a number greater than 1. This command will delete the migration file and any changes that were made in the database.

In some cases, you may need to delete a migration and all of the changes that were made with it. You can do this by running the migrate:reset command:


php artisan migrate:reset

This command will delete all of the migrations and any changes that were made in the database. It is important to note that this command is destructive and should not be used lightly.

Deleting a migration in Laravel is a simple process. It is important to understand what you are doing and how the commands work before running them. Once you understand the process, you can easily delete migrations and keep your database up-to-date.

Answers (0)