N
N
Nikolai Markov2014-10-24 11:33:09
PostgreSQL
Nikolai Markov, 2014-10-24 11:33:09

What are the pitfalls of using foreign keys in Rails (postgres)?

There is a worker that does long calculations and in the process of its work creates new records in the database (creates mails), but in the process of creating mails, the mail_group to which they belong can be deleted.

class Mail
  belongs_to :mail_group
end

I'm thinking of using foreign keys to monitor the existence of a group while creating new emails.
Another idea came up to use two-phase deletion, i.e. the group is marked as deleted, but is not deleted as long as there are running workers and each worker at the end of its work "attempts to delete the group".

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question