Is there a Rails gem, plugin or other means to automatically add or remove ALL RI constraints from your DB and schema? Or ALL of them on a per table basis? Something like:
remove_all_foreign_key_constraints(‘comments’)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No gems/plugins I’m aware of.
This is tricky though because rails (and most adapters) assume the referential integrity is maintained through your application’s association.
If that’s the case (associations ARE maintained in models), then you could write a little script that would construct the required SQL statements based on the model’s association.
Association reflection might help:
http://api.rubyonrails.org/classes/ActiveRecord/Reflection/ClassMethods.html#method-i-reflect_on_all_associations