繁体   English   中英

Laravel - SQLSTATE [42000]:语法错误或访问冲突:迁移时为1064

[英]Laravel - SQLSTATE[42000]: Syntax error or access violation: 1064 on migration

直到现在我运行php artisan migrate时才发生这个错误
我正在使用MySQL 5.6.34
我尝试了所有我能想到的东西):并且仍然没有运气我有一个类似的表,并且工作得很好但是由于某种原因,这曾经不起作用

[PDOException]
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax
  to use near 'unsigned not null, `address_1` varchar(191) unsigned not null, `address_2` varch' at line 1

这是我的迁移文件

public function up()
    {
        Schema::create('rmaRequests', function (Blueprint $table) {
           $table->increments('id');
           $table->integer('user_id')->unsigned();
           $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
           $table->string('reference_number')->unique();
           $table->string('first_name');
           $table->string('last_name');
           $table->string('email');
           $table->string('phone');
           $table->string('fax');
           $table->string('company');
           $table->integer('marketplaceId')->unsigned();
           $table->string('order_number')->unsigned();
           $table->string('address_1');
           $table->string('address_2');
           $table->string('city');
           $table->string('state');
           $table->string('zip');
           $table->integer('returnTypeId')->unsigned();
           $table->string('sku');
           $table->string('qty');
           $table->string('productName');
           $table->text('comments');
           $table->integer('status_id')->unsigned();
           $table->string('replacement_tracking');
           $table->string('return_tracking');
           $table->string('rma_number');
           $table->string('refund_number');
           $table->timestamps();
        });
    }



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

我认为这是因为你使用unsignedvarchar

这里:

$table->string('order_number')->unsigned();

Laravel描述中的unsigned()方法:

integer列设置为UNSIGNED

有关详细信息,请访问: https//laravel.com/docs/5.4/migrations#column-modifiers

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM