0
0
Laravelframework~5 mins

Migration creation in Laravel - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a migration in Laravel?
A migration is a way to create and modify database tables using PHP code. It helps keep database structure consistent and easy to share.
Click to reveal answer
beginner
How do you create a new migration file in Laravel?
Use the command php artisan make:migration create_table_name in the terminal. This creates a new migration file in the database/migrations folder.
Click to reveal answer
beginner
What are the two main methods inside a Laravel migration class?
The two main methods are up() and down(). up() defines the changes to apply, like creating tables. down() reverses those changes.
Click to reveal answer
beginner
Why should you use migrations instead of manually changing the database?
Migrations keep your database changes organized and version-controlled. They make it easy to share changes with others and rollback if needed.
Click to reveal answer
beginner
What command runs all pending migrations in Laravel?
Use php artisan migrate to apply all new migrations and update the database structure.
Click to reveal answer
Which command creates a new migration file in Laravel?
Aphp artisan migrate:rollback
Bphp artisan migrate
Cphp artisan db:create
Dphp artisan make:migration
What does the up() method in a migration do?
ADefines the changes to apply to the database
BReverts database changes
CDeletes the migration file
DRuns database seeders
Where are migration files stored in a Laravel project?
Aapp/Models
Bresources/views
Cdatabase/migrations
Dpublic/migrations
Which command applies all new migrations to the database?
Aphp artisan migrate
Bphp artisan migrate:rollback
Cphp artisan make:migration
Dphp artisan db:seed
What is the purpose of the down() method in a migration?
ATo apply new changes
BTo reverse the changes made by <code>up()</code>
CTo create a new migration file
DTo seed the database
Explain the process of creating and running a migration in Laravel.
Think about the commands and methods involved.
You got /4 concepts.
    Why are migrations important for managing database changes in a Laravel project?
    Consider teamwork and safety in database updates.
    You got /4 concepts.