I currently have two tables Symbols and Prices. I am currently creating a migration for Prices and adding a FK constraint to Prices.symbol_id which references Symbols.id. This is the Prices migration:
$table->increments('id');
...
...
$table->integer('symbol_id');
$table->foreign('symbol_id')
->references('id')->on('Symbols')
->onDelete('cascade’);
Symbols.id is simply a $table->increments(‘id’);
However, when I run the migration, this is what happens:
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter
table `Prices` add constraint prices_symbol_id_foreign foreign key (`symbol_id`) re
ferences `Symbols` (`id`))
[PDOException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
Any ideas why?