首页 > 其他 > 详细

Laravel 5 Migrations

时间:2016-08-22 19:57:28      阅读:228      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!