0
0
Laravelframework~5 mins

Running and rolling back migrations in Laravel - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command do you use to run all pending migrations in Laravel?
Use php artisan migrate to run all migrations that have not been applied yet. This updates your database schema to the latest version.
Click to reveal answer
beginner
How do you rollback the last batch of migrations in Laravel?
Use php artisan migrate:rollback to undo the last batch of migrations that were run. This helps if you want to revert recent database changes.
Click to reveal answer
intermediate
What does the migrate:reset command do?
The php artisan migrate:reset command rolls back all migrations, undoing all database schema changes made by migrations.
Click to reveal answer
intermediate
How can you rollback and then re-run all migrations in one command?
Use php artisan migrate:refresh. It rolls back all migrations and then runs them again, useful for rebuilding the database schema from scratch.
Click to reveal answer
beginner
Why is it important to run migrations carefully in a team environment?
Because migrations change the database structure, running them without coordination can cause conflicts or data loss. Teams should communicate and use version control to keep migrations in sync.
Click to reveal answer
Which command runs all new migrations in Laravel?
Aphp artisan migrate
Bphp artisan migrate:rollback
Cphp artisan migrate:reset
Dphp artisan migrate:refresh
What does php artisan migrate:rollback do?
AResets all migrations
BRuns all migrations
CRolls back the last batch of migrations
DRefreshes the database
Which command rolls back all migrations at once?
Aphp artisan migrate:reset
Bphp artisan migrate:refresh
Cphp artisan migrate
Dphp artisan migrate:rollback
How do you rollback and re-run all migrations in one step?
Aphp artisan migrate:rollback
Bphp artisan migrate:reset
Cphp artisan migrate
Dphp artisan migrate:refresh
Why should teams coordinate when running migrations?
ABecause migrations are slow
BTo avoid database conflicts and data loss
CTo speed up migration commands
DBecause migrations only run once
Explain how to run migrations and rollback the last batch in Laravel.
Think about commands to apply and undo changes.
You got /2 concepts.
    Describe the difference between migrate:reset and migrate:refresh commands.
    One just undoes, the other undoes and reapplies.
    You got /2 concepts.