Writing migrations

To create migration files in Lumen, we can use this command in the blog directory to create migration file:

php artisan make:migration create_users_table

You will see something similar to this:

Created Migration: 2017_06_23_180043_create_users_table

and a file with this name will be created in the /blog/database/migrations directory. In this file, we can write migration code for the Users table. If you open the file and look into it, there are 2 methods in it: up() and down(). up() method executes when it has to run migration while down() executes when it has to rollback migration.

Here is the content of this User table creation migration file:

<?phpuse Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint; ...

Get Building RESTful Web Services with PHP 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.