Search
 
SCRIPT & CODE EXAMPLE
 

SQL

SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

Add it in two steps, and it's good to make it unsigned too:

public function up()
{
    Schema::create('priorities', function($table) {
        $table->increments('id', true);
        $table->integer('user_id')->unsigned();
        $table->string('priority_name');
        $table->smallInteger('rank');
        $table->text('class');
        $table->timestamps('timecreated');
    });

   Schema::table('priorities', function($table) {
       $table->foreign('user_id')->references('id')->on('users');
   });

}
Comment

PREVIOUS NEXT
Code Example
Sql :: ajouter une clé etrangere mysql 
Sql :: delete role postgres 
Sql :: get last three characters in mysql column 
Sql :: t-sql get duplicate rows 
Sql :: oracle undo usage 
Sql :: insert a select statement into a table 
Sql :: convert date to datetime sql 
Sql :: scaffold mysql database 
Sql :: delete all content in table mysql 
Sql :: mysql update table from another table 
Sql :: racle create auto increment column 
Sql :: incorrect string value: mysql 
Sql :: mysql find missing values 
Sql :: check mysql username and password ubuntu 
Sql :: table or view does not exist 
Sql :: select index table oracle 
Sql :: delete temp table if exists 
Sql :: sql server: difference between hashtable and table declared using declare keyword 
Sql :: allow external access to mysql 
Sql :: mysql url 
Sql :: copy postgres table from one schema into another 
Sql :: import large .sql files into lampp 
Sql :: connect to ssms with python 
Sql :: mysql alter table add column first 
Sql :: postgresql create query 
Sql :: mysql on update current_timestamp 
Sql :: to date oracle 
Sql :: compare date mysql 
Sql :: mysql regexp_replace remove html tag 
Sql :: postgres list databases 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =