Fix addForeignKeys() method

$name is never defined here. I am pretty sure you meant for it to be the table name, so fetch that at the top.