我绞尽脑汁想弄清楚这一点,但无济于事。请帮忙。
我有以下代码:
Schema::create('inventory_category_relations', function(Blueprint $table)
{
$table->increments('id');
$table->integer('inventory_category_id')->unsigned()->nullable()->default(null);
$table->foreign('inventory_category_id')->references('id')->on('inventory_categories');
$table->integer('inventory_id')->unsigned()->nullable()->default(null);
$table->foreign('inventory_id')->references('id')->on('inventory');
$table->timestamps();
$table->softDeletes();
});
上面的代码引用了一个 'inventory' 和 'inventory_categories' 表,这些表已经被其他表创建和引用,它们工作得很好。但是,每次我尝试使用上面的代码运行“php artisan migrate”时,我的终端都会崩溃。
编辑 这是我原来的“inventory”和“inventory_categories”创建语句:
Schema::create('inventory_categories', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
Schema::create('inventory', function(Blueprint $table)
{
$table->increments('id');
$table->string('title');
$table->mediumText('basic_description');
$table->unsignedInteger('inventory_type_id');
$table->foreign('inventory_type_id')->references('id')->on('inventory_types')->onDelete('cascade');
$table->unsignedInteger('vendor_id');
$table->foreign('vendor_id')->references('id')->on('vendors')->onDelete('cascade');
$table->unsignedInteger('inventory_category_id');
$table->foreign('inventory_category_id')->references('id')->on('inventory_categories')->onDelete('cascade');
$table->decimal('price',10,2);
$table->decimal('compare_price',10,2);
$table->integer('quantity');
$table->string('sku');
$table->string('barcode');
$table->boolean('no_stock_purchase')->default(0);
$table->boolean('shipping_address')->default(0);
$table->decimal('shipping_weight')->default(0);
$table->boolean('free_shipping')->default(0);
$table->boolean('taxes')->default(1);
$table->boolean('multiple_options')->default(0);
$table->boolean('custom_variants')->default(0);
$table->boolean('active')->default(1);
$table->boolean('has_publish_date')->default(0);
$table->dateTime('start_date');
$table->dateTime('end_date');
$table->string('url');
$table->string('meta_title');
$table->mediumText('meta_description');
$table->boolean('has_commission')->default(0);
$table->unsignedInteger('created_by');
$table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
$table->softDeletes();
});
我在 wamp 服务器上使用 laravel 4.2
更新: 好的,我使用“php artisan migrate > migrate_error.log”并将结果发布到 pastebin。该文件太大,但我发布了适合的内容:http: //pastebin.com/J8KZn7R5