Make job belong to another model
Hi, I would like to know if there is a way to attribute a solid_queue_job to another model like a User, and now that separate databases are being encouraged I can't use a join table, and I am not sure if adding a user_id field to the solid_queue_job is a good idea or not. Thank you so much!
Hey @eliklein02! I think I'd do this in the other direction, perhaps having a solid_queue_job_id in the users table instead, or using a join table 🤔 It'd also depend on how the relationship works (can a user have multiple jobs? or just one?). You can still do this even if Solid Queue's tables are in a different DB. What you can't do is use JOIN across these tables, but you can have references in them.
Thank you for your response, @rosa! So the user can have multiple jobs. I guess then my best option is to create a table with User as a reference and the job_id as a string, with whatever other information I need to store (like when it is supposed to run) and use this to query. That will work. Thank you so much.