0
0
Laravelframework~10 mins

Migration creation in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new migration file using Artisan.

Laravel
php artisan [1] create_users_table
Drag options to blanks, or click blank then click option'
Adb:seed
Bmigrate
Cmake:migration
Droute:list
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'migrate' instead of 'make:migration' creates the tables but does not create the migration file.
Using 'db:seed' is for adding data, not creating migrations.
2fill in blank
medium

Complete the migration class name to follow Laravel conventions.

Laravel
class [1] extends Migration
Drag options to blanks, or click blank then click option'
ACreateUsersTable
Busers_table
Ccreate_users
DMigrationUsers
Attempts:
3 left
💡 Hint
Common Mistakes
Using snake_case or lowercase names for classes.
Using generic names that don't describe the migration.
3fill in blank
hard

Fix the error in the migration method to create a table named 'posts'.

Laravel
Schema::[1]('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->timestamps();
});
Drag options to blanks, or click blank then click option'
Atable
Bupdate
Cdrop
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' or 'drop' instead of 'create' causes errors or deletes tables.
Using 'table' is not a valid Schema method.
4fill in blank
hard

Fill both blanks to add a nullable string column named 'description' to the table.

Laravel
$table->[1]('[2]')->nullable();
Drag options to blanks, or click blank then click option'
Astring
Bdescription
Ctext
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' instead of 'string' changes the column type.
Using wrong column names like 'title' instead of 'description'.
5fill in blank
hard

Fill all three blanks to drop the 'users' table in the down method.

Laravel
Schema::[1]('[2]', function (Blueprint $table) {
    $table->id();
});

// inside the down() method
public function down()
{
    Schema::[3]('[2]');
}
Drag options to blanks, or click blank then click option'
Acreate
Busers
CdropIfExists
Dtable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'drop' instead of 'dropIfExists' can cause errors if the table does not exist.
Using wrong table names or methods.