Laravel 4 Tutorial Part 2 – Migrations and Artisan
Migrations
Migrations Installation
migrate:install
: it will crate a migrations table for record any changes of database.
1 |
$ php artisan migrate:install |
Making a new migration record
migrate:make (create|remove)_tablename_table
1 |
$ php artisan migrate:make create_authors_table |
The --table
and --create
options may also be used to indicate the name of the table, and whether the migration will be creating a new table:
$ php artisan migrate:make create_authors_table --table=authors --create
1 2 3 4 5 6 7 8 9 10 |
// up() Schema::create('authors', function($table){ $table->increments('id'); $table->string('name'); $table->text('bio'); $table->timestamp(); }); // down() Schema::drop('authors'); |
Running All Outstanding Migrations
$ php artisan migrate
To seed your database, you may use the db:seed command on the Artisan CLI:
$ php artisan db:seed
Rollback all migrations and run them all again
$ php artisan migrate:refresh --seed
Artisan
Check routes status:
$ php artisan routes
Clear auto-load files:
$ php artisan clear-compiled
Re-generate auto-load files:
$ php artisan dump-autoload