when I run
php artisan migrate
to migrate this 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'); }); }
I get this error message
IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘unsigned not null,
id_DeviceType
varchar(255) unsigned not null,id_DeviceBra' at line 1 (SQL: create table
transaction_ins(
idbigint unsigned not null auto_increment primary key,
idTransactionINvarchar(255) not null,
buy_datedate not null,
id_Suppliervarchar(255) unsigned not null,
id_DeviceTypevarchar(255) unsigned not null,
id_DeviceBrandvarchar(255) unsigned not null,
device_namevarchar(255) not null,
device_namemediumtext not null,
device_pricedecimal(11, 2) not null,
amountint not null,
sum_pricedecimal(15, 2) not null,
contextmediumtext not null,
created_attimestamp null,
updated_at` timestamp null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)
Advertisement
Answer
You can’t have strings unsigned, that’s meant for integers
just remove the unsigned modifier (if they are really strings)
$table->string('id_Supplier'); $table->string('id_DeviceType'); $table->string('id_DeviceBrand');
Hope this helps