zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    (十)条件判断
    (九)字符处理命令
    (八)awk命令
    (六)环境变量配置文件
    (七)grep命令行提取符号
    Ⅶ 类模板与STL编程 ②
    Ⅵ 虚函数与多态性
    Ⅴ 运算符重载
    Ⅳ 继承与派生②
    Ⅳ 继承与派生①
  • 原文地址:https://www.cnblogs.com/qike/p/5796664.html
Copyright © 2011-2022 走看看