Reputation: 75
when running "php artisan migrate:fresh" command it shows SQLSTATE[42000] error
Here is the full error message
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, created_at
timestamp null, updated_at
timestamp null) def' at line 1 (SQL: create table products
(id
bigint unsigned not null auto_increment primary key, name
varchar(191) not null, description
varchar(1000) not null, quantity
int unsigned not null, status
varchar(191) not null default 'unavailable', image
varchar(191) not null default 'unavailable', seller_id
varchar(191) unsigned not null, created_at
timestamp null, updated_at
timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
and here is the migration Product::UNAVAILABLE_PRODUCT is defined in Product model as 'unavailabel'
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description',1000);
$table->integer('quantity')->unsigned();
$table->string('status',)->default(Product::UNAVAILABLE_PRODUCT);
$table->string('image',)->default(Product::UNAVAILABLE_PRODUCT);
$table->string('seller_id',)->unsigned();
$table->timestamps();
$table->foreign('seller_id')->references('id')->on('users');
});
}
Upvotes: 0
Views: 1917
Reputation: 562348
$table->string('seller_id',)->unsigned();
There's no such thing as an unsigned string. Either remove the unsigned()
option for this column, or else define it as an integer.
Upvotes: 6