2 ms·
It's not user defined in db/schema.rb. When using migrations, the schema is written to that file. It's entirely possible to bring a legacy database to the app a
by nobleach 14y ago
It's not user defined in db/schema.rb. When using migrations, the schema is written to that file. It's entirely possible to bring a legacy database to the app and never create a migration. Rails just reads the table definitions from the database.
I think the schema.rb file CAN be used to build the database though... I'm trying to remember. I feel like I've done that before.
This is good and bad. Good because it saves the developer from describing something that's already described in another area. Bad because it takes away a bit of control.
My Django apps had a bunch of legacy tables that I was forced to sit and document. I had to remember to go back and add another line every time I added another field. But, to be honest, it's pretty much the same way with most other frameworks I use.
- jarrett 14y ago> When using migrations, the schema is written to that file. You can also run rake db:schema:dump at any time. So it works great with a legacy database. You don't need to run any migrations for this to work.