且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

未找到 Laravel 4 迁移基表

更新时间:2022-01-05 06:19:29

在你的 CreateUserTable 迁移文件中,你必须使用 而不是 Schema::tableSchema::create.

In your CreateUserTable migration file, instead of Schema::table you have to use Schema::create.

Schema::table 用于更改现有表,Schema::create 用于创建新表.

The Schema::table is used to alter an existing table and the Schema::create is used to create new table.

查看文档:

所以您的用户迁移将是:

So your user migration will be:

<?php

use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;

class CreateUserTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user', function(Blueprint $table) {
        {

            $table->increments("id",true);
            $table->string("username")->nullable()->default(null);
            $table->string("password")->nullable()->default(null);
            $table->string("email")->nullable()->default(null);
            $table->timestamps();

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists("user");
    }

}