Migration
A migration
is a special class that contains a set of actions to run against the database, such as creating or modifying a database table. Migrations ensure your database gets set up identically every time you create a new instance of your app, for example, installing in production or on a teammate's machine.
To create a new migration, use the make:migration
Artisan CLI command. The argument of the command should be a snake-cased description of what the migration will do:
$ php artisan make:migration create_listings_table
You'll now see your new migration in the database/migrations
directory. You'll notice the filename has a prefixed timestamp, such as 2017_06_20_133317_create_listings_table.php
. The timestamp allows Laravel to determine the proper order of the migrations, in case it needs to run more than one at a time.
Your new migration declares a class that extends Migration
. It overrides two methods: up
, which is used to add new tables, columns, or indexes to your database; and...