语法错误或访问冲突:1075错误的表定义;只能有一个自动列,并且必须将其定义为键

时间:2019-02-22 14:36:42

标签: migration laravel-5.6

我阅读了所有相关问题,但是找不到迁移文件无法正常工作的原因。也许比我更有天赋的人会立即发现原因:

    public function up()
{
    Schema::create('orders_detail', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('orderID', 11)->nullable()->unsigned();
        $table->integer('userID', 11)->unsigned();
        $table->integer('roleID', 11)->unsigned();
        $table->integer('ownership', 11)->nullable()->unsigned();
        $table->integer('ownerID', 11)->nullable()->unsigned();
        $table->integer('ownerroleID', 11)->nullable()->unsigned();
        $table->integer('customerID', 11)->nullable()->unsigned();
        $table->integer('statusorderID', 11)->unsigned();
        $table->integer('statuslaboID', 11)->unsigned();
        $table->date('delivery_date');
        $table->integer('producttypeID', 11)->unsigned();
        $table->integer('productname', 11);
        $table->string('laboratory', 100);
        $table->integer('dessertservingID', 11)->nullable()->unsigned();
        $table->integer('dessertsizeID', 11)->nullable()->unsigned();
        $table->string('desserttextmessage', 200)->nullable();
        $table->string('dessertdecorchocolateID', 200)->nullable();
        $table->string('dessertdecorflowerID', 200)->nullable();
        $table->integer('partyloaftypeID')->nullable()->unsigned();
        $table->integer('partyloafportionID', 11)->nullable()->unsigned();
        $table->integer('partyloafweightID', 11)->nullable()->unsigned();
        $table->integer('partyloafsandwich1ID', 11)->nullable()->unsigned();
        $table->integer('partyloafsandwich2ID', 11)->nullable()->unsigned();
        $table->integer('partyloafsandwich3ID', 11)->nullable()->unsigned();
        $table->integer('partyloafsandwich4ID', 11)->nullable()->unsigned();
        $table->integer('partyloafribbonID', 11)->nullable()->unsigned();
        $table->double('productprice', 10, 2)->default('0.00');
        $table->double('productaddfee', 10, 2)->default('0.00');
        $table->double('subtotal', 10, 2)->default('0.00');
        $table->double('total', 10, 2)->default('0.00');
        $table->timestamps();
        $table->SoftDeletes();
    });
}

干杯,马克

2 个答案:

答案 0 :(得分:0)

可以解决它:

    public function up()
{
    Schema::create('orders_detail', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('orderID')->unsigned()->nullable();
        $table->integer('userID')->unsigned();
        $table->integer('roleID')->unsigned();
        $table->integer('ownership')->unsigned()->nullable();
        $table->integer('ownerID')->unsigned()->nullable();
        $table->integer('ownerroleID')->unsigned()->nullable();
        $table->integer('customerID')->unsigned()->nullable();
        $table->integer('statusorderID')->unsigned();
        $table->integer('statuslaboID')->unsigned();
        $table->date('delivery_date');
        $table->integer('producttypeID')->unsigned();
        $table->integer('productname');
        $table->string('laboratory', 100);
        $table->integer('dessertservingID')->unsigned()->nullable();
        $table->integer('dessertsizeID')->unsigned()->nullable();
        $table->string('desserttextmessage', 200)->nullable();
        $table->string('dessertdecorchocolateID', 200)->nullable();
        $table->string('dessertdecorflowerID', 200)->nullable();
        $table->integer('partyloaftypeID')->unsigned()->nullable();
        $table->integer('partyloafportionID')->unsigned()->nullable();
        $table->integer('partyloafweightID')->unsigned()->nullable();
        $table->integer('partyloafsandwich1ID')->unsigned()->nullable();
        $table->integer('partyloafsandwich2ID')->unsigned()->nullable();
        $table->integer('partyloafsandwich3ID')->unsigned()->nullable();
        $table->integer('partyloafsandwich4ID')->unsigned()->nullable();
        $table->integer('partyloafribbonID')->unsigned()->nullable();
        $table->double('productprice', 10, 2)->default('0.00');
        $table->double('productaddfee', 10, 2)->default('0.00');
        $table->double('subtotal', 10, 2)->default('0.00');
        $table->double('total', 10, 2)->default('0.00');
        $table->timestamps();
        $table->SoftDeletes();
    });
}

答案 1 :(得分:0)

如果要指定整数列的长度,然后按照以下方法进行操作

$table->bigInteger('orderID'')->length(11);