2014-02-24 122 views
0

我已经创建了一个运行我的品牌新的Laravel项目中的以下迁移:Laravel迁移创建迁移表,而不是用户的预期

<?php 

use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 

class CreateUsersTable extends Migration { 

    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::table('users', function(Blueprint $table) 
     { 
      $table->increments('id'); 

      $table->string('name', 255); 
      $table->string('email', 255); 
      $table->integer('user_level'); 

      $table->timestamps(); 
     }); 
    } 

    /** 
    * Reverse the migrations. 
    * 
    * @return void 
    */ 
    public function down() 
    { 
     Schema::drop('users'); 
    } 

} 

我本来期望它来创建一个users表的姓名,电子邮件,等等,但我最终得到的是migration表。我做错了什么?

+0

您是否使用工匠生成迁移文件? – marcanuy

回答

1

试试这个

Schema::create('users', function(Blueprint $table){ 
     table->increments('id'); 
     $table->string('name', 255); 
     $table->string('email', 255); 
     $table->integer('user_level'); 
     $table->timestamps(); 
}); 

migration表由laravel跟踪你已经完成了迁移和回滚。

+1

添加到此 - Schema :: create用于创建新表,Schema :: table用于修改现有的表。 – Andreas