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?
✗ Incorrect
The command
php artisan make:migration creates a new migration file.What does the
up() method in a migration do?✗ Incorrect
The
up() method defines the changes like creating or modifying tables.Where are migration files stored in a Laravel project?
✗ Incorrect
Migration files are stored in the
database/migrations folder.Which command applies all new migrations to the database?
✗ Incorrect
The
php artisan migrate command runs all pending migrations.What is the purpose of the
down() method in a migration?✗ Incorrect
The
down() method reverses the changes made by up().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.