Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Migration vs model

I'm having trouble understanding the rationale behind Rails migrations, and I hope I can articulate my question well enough to get an answer. If I were designing Rails, I would think that the most natural place for the database schema would be in the model where it can be reasoned about as a single unit. A User's attributes, like name and email, sit in the same place as their relationships and scopes. Instead, the User's columns are defined in one (possibly more) files that run in sequence.

I'm not saying that I'm right or that Rails is crap, but can anyone here explain why it's such a good idea to have schemas defined this way? What benefit do we have over simply defining a table in one place, one time?