gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 06:35:46 25 4
gpt4 key购买 nike

直到现在我运行 php artisan migrate 时才发生此错误
我正在使用 MySQL 5.6.34
我尝试了所有我能想到的方法):但仍然没有运气我有一张与此类似的 table 并且工作正常但由于某种原因,这一次不起作用

[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');
}

最佳答案

我认为这是因为您对 varchar 使用了 unsigned

这里:

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

Laravel 描述中的unsigned() 方法:

Set integer columns to UNSIGNED

更多信息:https://laravel.com/docs/5.4/migrations#column-modifiers

关于php - Laravel - SQLSTATE [42000] : Syntax error or access violation: 1064 on migration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45928955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com