Deleting models, migrations, controller due to ( foreign key constraint)


When creating my schema, I created “Inspections” model,migration and controller before “Vendors” model,migration,controller.

Now I have a foreign key constraint, because I should have created Vendors first, Inspections second.

Can I simply right-click delete the migration table only ( or all 3, model,migration,controlerl) and re-create it in the proper order.

Or is there a proper way I am supposed to do this so I don’t have possible future issues?



When you create a migration file, you are prompted to whether you want to create a fresh new one or select an existing one. If you choose the later, you can then modify your schema file where you will see this the alter function:

up () {
  this.alter('users', (table) => {
    // add new columns or remove existing

What you add there, you must roll it back in the down() function accordingly.

If you are at the beginning of your project, it is just better to drop your database and modify the content of your migration files and/or rename them.