Using Rails migrations with PostgreSQL
If you’re like me—and I hope you are—you use PostgreSQL and believe in implementing multiple layers of data protection, where appropriate. For example, I do implement foreign keys and nullability in the database. To me this is just good behavior. One of the things I ran into with using the Rails migration capability was dealing with some of the more advanced capabilities of PostgreSQL. Often, I’d just roll the foreign keys and nullability stuff in the DDL and go from there. Unfortunately, as I’m building incrementally, I really don’t want everything at once. So, after reading a post by Robby, I decided to use his strategy and implement a schema version that adds constraints. This lets me decide when to bring them into the equation. Too early, and it’s hard to sketch out the application; too late, and data could be corrupted.
I also use another version to bring in the preloaded data in the database. Nifty. Now, if only I could use the schema creation facility that doesn’t require me using DDL, but I’m simply too dependent on certain fixtures in PostgreSQL that aren’t available yet.
This entry was posted at 8:05 pm on 21 February 2006 and is filed under PostgreSQL, Ruby. You can follow any responses to this entry through the post-specific RSS 2.0 feed.
No comments found.
Responses are currently closed, but you can trackback from your own site.