我的代码:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tasks', function (Blueprint $table) {
$table->increments('id');
$table->integar('user_id')->index();
$table->string('name');
$table->string('food');
$table->string('quantity');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('tasks');
}
}
你错误地写了integer
拼写,写这个integer
而不是integar
这是我的工作示例代码,请参阅整数行,希望对您有帮助
public function up()
{
Schema::create('app_type_users', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->integer('app_type_id')->unsigned()->index();
$table->string('status',1);
$table->timestamps();
});
}
转到你的项目文件夹打开app/Providers/AppServiceProvider.php
添加以下代码然后在控制台中运行php artisan migrate
。
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}