I'm trying to relate one field to another using migrations this way:
Butwhendoingtheforeignkeyinmigrationsthisway:
MigrationPermission:
Schema::create('permissions',function(Blueprint$table){$table->increments('id');$table->index('user_id');$table->timestamps();});
MigrationUser:
Schema::create('users',function(Blueprint$table){$table->string('id',100)->primary();//CódigoOmitido...});Schema::table('permissions',function($table){$table->foreign('user_id')->references('id')->on('users');});
Errorgettingterminal:
Illuminate\Database\QueryException:SQLSTATE[42000]:Syntaxerrororaccessviolation:1072Keycolumn'user_id'doesn'texistintable(SQL:altertable
permissionsaddindex
permissions_user_id_index(
user_id))1PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'user_id' doesn't exist in table") D:\Infinity\vendor\laravel\framework\src\Illuminate\Database\Connection.php : 458 2 PDOStatement::execute() D:\Infinity\vendor\laravel\framework\src\Illuminate\Database\Connection.php : 458