bizhanmp
1018
5
Requests

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in you r SQL syntax;

Posted 4 years ago by bizhanmp

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?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.