Foreing Key Creation Adonisjs

I continually get the following error:

sqlMessage: ‘Can’t create table [DB_NAME].#sql-d981_12d (errno: 150 “Foreign key constraint is incorrectly formed”)’,

Here is the code that I am using to create the foreign key:

.onDelete(‘SET NULL’)

Any help will be appreciated. I’ve been on Knex.js and followed the instructions to the letter.

Is FK and the PK on the other table using the same data type ?

Yes, they are both integers. My apologies. The PK in table A is auto Increment and the FK in table B is an integer.

Virk, I finally found the solution. I had to place my migration files in a specific order. I placed my last migration file last that had multiple FK’s. After doing this, the migration worked with no issues.

Thanks for your help.