11.08.2017 Views

codebright

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Migrations 253<br />

Simply change the migrations index to the name of the table which you wish to use to track your<br />

migration status. A sensible default has been provided.<br />

We can install our migrations table by running another Artisan command. Let’s run the install<br />

command now.<br />

1 $ php artisan migrate:install<br />

2 Migration table created successfully.<br />

Now let’s examine our database, and look for the migrations table to see what has been created.<br />

1 mysql> describe migrations;<br />

2 +-----------+--------------+------+-----+---------+-------+<br />

3 | Field | Type | Null | Key | Default | Extra |<br />

4 +-----------+--------------+------+-----+---------+-------+<br />

5 | migration | varchar(255) | NO | | NULL | |<br />

6 | batch | int(11) | NO | | NULL | |<br />

7 +-----------+--------------+------+-----+---------+-------+<br />

8 2 rows in set (0.01 sec)<br />

A new table with two fields has been created. Don’t trouble yourself with the implementation of<br />

the migrations table, just rest assured that it has been created, and the migrations system has been<br />

installed.<br />

Okay, well I have lied to you again. I don’t know how this keeps happening? Perhaps I should visit<br />

a psychiatrist or something. Well anyway, I told you that we needed to install the migrations table,<br />

and I lied.<br />

You see, Laravel will automatically create the table for us if it doesn’t exist when your migrations are<br />

executed. It will install the migrations system for you. At least you know about the migrate:install<br />

command now though right? It’s almost as if I planned this whole deception…<br />

Right, let’s get started and run our migration for the first time. We can use the migrate command<br />

to do this.<br />

1 $ php artisan migrate<br />

2 Migrated: 2013_06_30_124846_create_users<br />

The output from the command is a list of migrations that have been executed. Let’s take a look at<br />

our database to see if our ‘users’ table has been created.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!