码迷,mamicode.com
首页 > 其他好文 > 详细

Laravel 5 Migrations

时间:2016-08-22 20:00:10      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

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

Laravel 5 Migrations

标签:

原文地址:http://www.cnblogs.com/qike/p/5796664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!