Creating data tables using migrations and schemas
Using Laravel, we can easily create our data model using schemas and migrations. In this recipe, we'll see some basic functionality of how Laravel accomplishes this.
Getting ready
For this recipe, we need a standard Laravel installation, as well as a MySQL database configured in our database config file.
How to do it...
To complete this recipe, follow these steps:
Install our migrations table from the command prompt, using
artisan
:php artisan migrate:install
Create a migration to hold our Schema code for creating a new table:
php artisan migrate:make create_shows_table
In our
app/database/migrations
directory, locate the file that should be named similar to2012_01_01_222551_create_shows_table.php
. Add the schema to create our table and add the columns:class CreateShowsTable extends Migration { /** * Make changes to the database. * * @return void */ public function up() { Schema::create('shows', function...