I have 2 foreign keys, one works and the other gives a malformed error
1.-
public function change(): void
{
$refTable = $this->table('bitacora')
->addForeignKey('id_bitacora', 'comunidades', 'id_comunidad', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
->save();
}
In the botacora table the id has been changed to id_bitacora as follows
$bitacora = $this->table('bitacora',['id' => false, 'primary_key'=> ['id_bitacora']]);
$bitacora->addColumn('id_bitacora', 'integer', ['null' => false])
2.- This doesn’t work and gives an error:
public function change(): void
{
$refTable = $this->table('admins')
->addForeignKey('id', 'comunidades', 'id_comunidad', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
->save();
}
PDOException: SQLSTATE[HY000]: General error: 1005 Can't create table `servpcspa_syscon`.`admins` (errno: 150 "
Foreign key constraint is incorrectly formed") in /home/servpcspa/web/servpcspa.com/public_html/vendor/robmorga
n/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:203