Hacker News new | ask | show | jobs
Show HN: Enforced, Annotated Schema for Ruby Sequel Models (github.com)
22 points by karthikksv 3859 days ago
2 comments

I use the annotate gem in all my RoR projects. It adds comments to the model files based on the structure of the DB table. I find it very helpful. Haven't really thought about taking it a step further and _enforcing_ it with code.

https://github.com/ctran/annotate_models

Ah, yes, I've used something similar in the past too. It's great for being able to see what fields you can access, but it's not guaranteed to be up-to-date with the database.

I think the biggest problem for our team is that people will have differing migrations on their respective branches. When they move around to other branches, these migrations will cause parts of the code to break, and it can be difficult to diagnose why. Enforcing the schema up front prevents these issues and helps us avoid stale/incorrect database state.

As far as I can tell from the README this suffers the same abstraction leak as most ORMs. Relations are not objects no matter how big your hammer is.