Put your code between ``` to style it, it's hard to read.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in you r SQL syntax;
i have to migration :
1-create_countries_table
" Schema::create('countries', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->timestamps();
}); "
2-create_cities_table
Schema::create('cities', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->smallInteger('country_id');
$table->timestamps();
$table->foreign('country_id')->refrences('id')->on('countries');
});
when i use php artisan migrate , i see thi error
"[Illuminate\Database\QueryException]
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 ')' at line 1 (SQL: alter table cities add constraint cities_country_id_foreign foreign key (country_id) references countries ())"
What is the problem?
I found my problem . i must use $table->integer('country_id')->unsigned(); because every increments determine int(10) by Laravel and just this foreign key definition is mach with int(10).
Please or to participate in this conversation.