LARAVEL
- Service Provider vs. Service Container: Understanding the Core of Dependency Injection
- Seeder vs Factories vs Faker in Laravel: A Complete Guide
- What is Blade? Understanding Laravel’s Template Engine
- Laravel Job Queue Full Guide: Asynchronous Processing for Scalable Apps
- Mastering Laravel Artisan: Boost Your Development with Powerful CLI Commands
- Laravel Helpers: Complete Guide with Benefits, Limitations & Best Practices (2025)
- Laravel Helpers vs Libraries vs Facades: Best Use Cases, Performance & When to Use Each
- Why Unit Testing Helpers Is Hard
- Laravel Library (Liberry): Full Guide – Features, Usage, Pros & Cons
- Laravel Middleware Complete Guide (2025): Types, Usage, Custom Middleware & Examples
- CSRF Protection in Laravel: Full Guide with Benefits, Drawbacks, and Implementation
- What Are Collections in Laravel?
- Laravel Eloquent Relationships(ORM)-Full Topic Coverage
- Laravel Cache – Complete Guide with Examples
- What is Composer and Why is it Required for Laravel?
- Understanding Laravel Facades: A Complete Guide
- What is Routing in Laravel? A Complete Guide
- What are Controllers in Laravel? A Complete Guide
- How to rollback last migration?
- Authentication vs Authorization: Understanding the Difference
- Laravel Guards: A Complete Guide
- How do you implement rate limiting in Laravel?
- Queues in Laravel: Everything You Need to Know
- Events and Listeners in Laravel: A Complete Guide
- Explain fillable vs guarded.
- How do you use scopes in Laravel?
- Understanding Migrations in Laravel: A Complete Guide
- What is Laravel broadcasting?
- What is Laravel Horizon?
- What are accessors and mutators in Eloquent?
- What is Soft Delete in Laravel?
- What is withTrashed() and onlyTrashed()?
- What is eager loading and lazy loading?
- Difference between php artisan migrate and php artisan migrate:fresh.
- What are seeders in Laravel?
- What are factories in Laravel?
- What are database transactions in Laravel?
- Difference between Schema::create() and Schema::table().
- What are Laravel hashing methods?
- What is XSS and how Laravel protects against it?
How to rollback last migration?
In Laravel, if you want to rollback the last migration, you can use the Artisan command:
php artisan migrate:rollback
Details:
- This command reverts the last batch of migrations that were run.
- If you ran multiple migrations at once, all migrations in the last batch will be rolled back, not just a single migration.
Optional Flags:
- Step-wise rollback (rollback only a specific number of migrations):
php artisan migrate:rollback --step=1
--step=1rolls back the last 1 migration.--step=2rolls back the last 2 migrations, and so on.
- Database connection (if using multiple connections):
php artisan migrate:rollback --database=your_connection_name
If you want to rollback all migrations:
php artisan migrate:reset
- This will undo all migrations in your database.
No comments yet! You be the first to comment.
