codestudiohq / laravel-totem

Manage Your Laravel Schedule From A Web Dashboard
MIT License
1.78k stars 224 forks source link

Cannot add foreign key constraint #105

Closed qerim closed 6 years ago

qerim commented 6 years ago

Hello, I've been getting Cannot add foreign key constraint when running php artisan migrate since the update to 3.2.4.

My table_prefix = totem_

 Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `totem_task_results` add constraint `task_id_fk` foreign key (`task_id`) references `tasks` (`id`))

  at C:\Projects\API\vendor\laravel\framework\src\Illuminate\Database\Connection.php: 664
  660:         // If an exception occurs when attempting to run a query, we'll format the error
  661:         // message to include the bindings with SQL, which will make this exception a
  662:         // lot more helpful to the developer instead of just the database's errors.
  663:         catch (Exception $e) {
  664:             throw new QueryException(
  665:                 $query, $this->prepareBindings($bindings), $e
  666:             );
  667:         }
  668:
  669:         return $result;

  Exception trace:

  1   Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint")
      C:\Projects\API\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php : 143

  2   PDOException::("SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint")
      C:\Projects\API\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php : 141

  Please use the argument -v to see more details.
qschmick commented 6 years ago

@qerim Sorry about that, forgot to include the optional table prefix in the foreign key section. Fixed in v3.2.5

qerim commented 6 years ago

@qschmick thanks for your fast response and maintaining this great package