Laravel 5 Migrations

Laravel migrations provide mechanisms for creating and modifying database tables. Migrations are database agnostic. This means you do not have to worry about the specific SQL syntax for the database engine that you are creating tables for. Migrations also allow you to roll back the most recent changes that you made to a database.

Create migration table
Run the following artisan command to create a migration table in Larashop database.
php artisan migrate:install
You will get the following message
Migration table created successfully.

$table->timestamps(); is used to automatically create two time stamp fields namely created_at and updated_at.

Database seeding
In this section, we are going to add dummy data to our database. Seeding is a term that is used to describe the process of adding test data to the database.

Larashop Database seeding
Let’s now add some dummy records to our database. 1. return to the command prompt 2. Run the following commands

php artisan make:seeder ProductsTableSeeder
php artisan make:seeder CategoriesTableSeeder
php artisan make:seeder BrandsTableSeeder

错误:
[ReflectionException] Class SongsTableSeeder does not exist
解决:
composer dump-autoload
to generate new class map

posted @ 2016-08-22 18:48  qike  阅读(161)  评论(0编辑  收藏  举报