Everything was working fine till I started using users tables id as a foreign key in blogs table and tried to migrate it into the database. I started getting errors of
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 synt ax to use near 'unsigned not null,
modelNamevarchar(191) not null,titlevarchar(191) not n' at line 1 (SQL: create tableblogs(idint unsigned not null auto_increment primary key,user_idvarchar(191) unsigned not null,modelNamevarchar(191) not null,titlevarchar(191) not null,priceint unsigned not null,descriptiontext not n ull,statusint not null,photo_idvarchar(191) not null,company_idvarchar(191) not null default '1',created_attimestamp null,updated_attimestamp null) default c haracter set utf8mb4 collate utf8mb4_unicode_ci) In Connection.php line 445: 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 synt ax to use near 'unsigned not null,modelNamevarchar(191) not null,titlevarchar(191) not n' at line 1**
here is the users table structure
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->integer('role_id')->index()->unsigned()->nullable();
$table->integer('is_active')->default(0);
$table->string('name');
$table->string('photo_id')->default('default.png');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
and here's the blogs table structure
public function up()
{
Schema::create('blogs', function (Blueprint $table) {
$table->increments('id');
$table->string('user_id')->unsigned();
$table->string('modelName')->index();
$table->string('title');
$table->integer('price')->unsigned();
$table->text('description')->nullable(false);
$table->integer('status');
$table->string('photo_id');
$table->string('company_id')->default(!null);
$table->timestamps();
// $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('user_id')->refrences('id')->on('users');
});
}
I have tried almost everything in my knowledge that could be going wrong and also tried solutions available online, but nothing seems to be working right now. Any help would be highly appreciated.