Migration Architect — Laravel

Design Laravel migrations: 10 levels of Schema, Blueprint, foreign keys and rollback. A Laravel migration game for backend engineers.

What you learn in this game

A migration in Laravel is a way to define and change the database structure using PHP code. Schema::create() makes a new table, while Schema::table() modifies an existing one.

Schema::table() is used to modify an existing table. When adding a new column to a table that already has data, the column usually needs nullable() or a default() so the old data doesn't error.

A foreign key links data across tables. In Laravel, foreignId() + constrained() is the concise way to make a foreign key. onDelete("cascade") means if the parent is deleted, the child is deleted too.

Soft delete is a technique where data isn't actually removed from the database, but marked with a timestamp in the deleted_at column. An index speeds up queries on a frequently-filtered column.