• 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

  • 相关阅读:
    Java操作数据库——使用JDBC连接数据库
    MySQL入门——Linux下安装后的配置文件
    Linux上搭建SVN服务
    PHP包管理工具composer
    收藏博文
    Linux上软件安装
    nginx配置详解
    Linux文本编辑器Vim使用
    Linux常用命令整理
    Linux增加swap空间
  • 原文地址:https://www.cnblogs.com/qike/p/5796664.html
Copyright © 2020-2023  润新知