美文网首页
Lumen项目 migrate Mysql

Lumen项目 migrate Mysql

作者: 大热天晒太阳 | 来源:发表于2017-05-31 19:15 被阅读172次
  1. 登录MySql 创建一个名字和lumen项目目录下.env文件里DB_DATABASE 名字一样的数据库.
  2. 执行php artisan migrate
  3. 进行填充,执行php artisan db:seed
  4. 刷新数据库结构并执行数据填充 php artisan migrate:refresh --seed
  5. 需要添加字段的话在迁移里添加:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFlightsTable extends Migration
{
    /**
     * 运行数据库迁移。
     *
     * @return void
     */
    public function up()
    {
        Schema::create('flights', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('airline');
            $table->timestamps();
        });
    }

    /**
     * 回滚数据库迁移。
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('flights');
    }
}

然后运行php artisan migrate:refresh --seed

相关文章

网友评论

      本文标题:Lumen项目 migrate Mysql

      本文链接:https://www.haomeiwen.com/subject/tsvjfxtx.html