- Migration Creation: We use Artisan to create a migration file for the
tasks
table. Migrations allow us to define the structure of the database in PHP code, making it easy to version control database changes. - Schema Definition: In the migration file, we define the schema for the
tasks
table, which includes:id
: An auto-incrementing primary key.title
: A string to store the task title.description
: A nullable text field for additional details.completed
: A boolean to track if the task is finished (defaulting tofalse
).timestamps
: Automatically managed fields for created and updated times.
- Running the Migration: By running
php artisan migrate
, we apply this migration, creating thetasks
table in the database.
Creating a Migration for Tasks