开发者

Adding and removing referential integrity constraints - automatically

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')


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜