【发布时间】:2015-12-21 16:22:03
【问题描述】:
我在 laravel 中声明了以下迁移文件:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products' , function($table){
$table->increments('id');
$table->integer('category_id');
$table->string('title');
$table->text('description');
$table->decimal('height' , 6 , 2);
$table->decimal('width' , 6 , 2);
$table->decimal('length' , 6 , 2);
$table->string('color');
$table->string('material');
$table->timestamps();
});
Schema::table('products' , function($table){
$table->foreign('category_id')->references('id')->on('categories');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('products');
}
}
现在当我运行php artisan migrate
我收到一个错误,因为类别中的 id 是 int(10) 而 categories_id I.E.
$table->foreign('category_id')->references('id')->on('categories');
是int(11) 我如何使两个 int(10) ?
【问题讨论】:
标签: php laravel-4 database-migration