rails / solid_queue

Database-backed Active Job backend
MIT License
1.84k stars 110 forks source link

Missing foreign keys according to `immigrant` #206

Closed ishigo974 closed 5 months ago

ishigo974 commented 5 months ago

Hi,

I'm using the gem immigrant in my CI in order to find potentially missing foreign_keys.

Since I added solid_queue, here is the error I have:

Missing foreign key relationship on 'solid_queue_claimed_executions.process_id' to 'solid_queue_processes.id'
Missing foreign key relationship on 'solid_queue_processes.supervisor_id' to 'solid_queue_processes.id'

As the gem offers to generate a migration fixing this issue, I just ran it so you can have a look at what it would create. Here it is:

  def change
    add_foreign_key "solid_queue_claimed_executions", "solid_queue_processes", column: "process_id", name: "solid_queue_claimed_executions_process_id_fk"
    add_foreign_key "solid_queue_processes", "solid_queue_processes", column: "supervisor_id", name: "solid_queue_processes_supervisor_id_fk"
  end

I'm not sure about the behaviour of these models, so would it be possible to tell me if I should ignore them or if some foreign keys are really missing here?

Thanks, Maxime

rosa commented 5 months ago

Hey @ishigo974, thanks for this! Yes, the gem is right, we could have added these two foreign keys. However, I decided not to add them because their advantages with respect to data integrity weren't that important in this case, and there are some drawbacks to foreign keys in general. In short, yes, you can ignore these 😊

ishigo974 commented 5 months ago

Thanks for your quick answer!