Laravel 6 - SQLSTATE [42000]: синтаксическая ошибка или нарушение доступа: 1064 В синтаксисе SQL есть ошибка; - PullRequest
0 голосов
/ 19 октября 2019

когда я запускаю

php artisan migrate

для переноса этого Schema

public function up()
{
    Schema::create('transaction_ins', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('idTransactionIN');
        $table->date('buy_date');
        $table->string('id_Supplier')->unsigned();
        $table->string('id_DeviceType')->unsigned();
        $table->string('id_DeviceBrand')->unsigned();
        $table->string('device_name');
        $table->mediumText('device_name');
        $table->decimal('device_price', 11, 2);
        $table->integer('amount');
        $table->decimal('sum_price', 15, 2);
        $table->mediumText('context');
        $table->timestamps();

        //Foreign Key
        $table->foreign('id_Supplier')->references('idSupplier')->on('suppliers')->onUpdate('cascade');
        $table->foreign('id_DeviceType')->references('idDeviceType')->on('device_types')->onUpdate('cascade');
        $table->foreign('id_DeviceBrand')->references('idDevicebrand')->on('device_brands')->onUpdate('cascade');
    });
}

Я получаю это сообщение об ошибке

Illuminate \ Database \ QueryException:SQLSTATE [42000]: синтаксическая ошибка или нарушение прав доступа: 1064 В синтаксисе SQL имеется ошибка;проверьте руководство, соответствующее вашей версии сервера MariaDB, на предмет правильного синтаксиса для использования рядом с 'unsigned not null, id_DeviceType varchar (255) unsigned not null, id_DeviceBra' at line 1 (SQL: create tableaction_ins ( id bigint unsigned not null auto_increment primary key, idTransactionIN varchar(255) not null, buy_date date not null, id_Supplier varchar(255) unsigned not null, id_DeviceType varchar(255) unsigned not null, id_DeviceBrand varchar(255) unsigned not null, имя_устройства varchar(255) not null, имя_устройства mediumtext not null, имя_устройства decimal(11, 2) not null, сумма int not null, сумма_приза decimal(15, 2) not null, контекст mediumtext not null, созданная_ат timestamp null, обновленная_ат_временная отметка ноль) набор символов по умолчаниюutf8mb4 collate 'utf8mb4_unicode_ci')

1 Ответ

1 голос
/ 19 октября 2019

Вы не можете иметь строки без знака, это предназначено для целых чисел

, просто удалите модификатор без знака (если они действительно строки)

$table->string('id_Supplier');
$table->string('id_DeviceType');
$table->string('id_DeviceBrand');

Надеюсь, это поможет

...