*scottstuff* : Auto-generating schema from Rails migrations /blog/2005/09/01/auto-generating-schema-from-rails-migrations?format=rss en-us 40 Comment on Auto-generating schema from Rails migrations by Bob Aman <p>Very nice. This is a great idea, not just for Typo, but for a lot of different things. I&#8217;ll probably try and incorporate something like this into FeedTools and TagTools.</p> Wed, 31 Aug 2005 15:15:37 -0700 urn:uuid:c26446cccb36b65cdb2701aa0b5136cb http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-855 Comment on Auto-generating schema from Rails migrations by Nathaniel Talbott <p>As I read this, it made me wonder: why have a schema at all? Why not just have migrations do the whole kit-n-caboodle, so they&#8217;ll take new users from no version to the current version, or upgrading users from their old version to the current version. The main concern I have with your current path is the corner cases and the fact that they may multiply over time.</p> <p>Just a thought.</p> Thu, 01 Sep 2005 06:00:26 -0700 urn:uuid:7d21ef8f30bec4b658f608f193f876de http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-1748 Comment on Auto-generating schema from Rails migrations by Scott Laird <p>Working without a schema and letting the DB generate everything from migrations will work, but I really like having a single file that I can look at that will tell me about each of the classes that ActiveRecord builds for me&#8211;I&#8217;d rather look at a file then drop into the DB and ask it. And trying to reconstruct the current state of a table by looking through a couple dozen migrations really sucks.</p> <p>Now, since my schema generator won&#8217;t work unless your migrations <em>already</em> describe how to migrate from an empty DB to a fully populated one, I guess this ends up being sort of moot&#8211;you can either tell users to run &#8216;rake migrate&#8217; to build the DB or use the packaged schema file.</p> <p>All except for Sqlite, that is&#8211;migrations don&#8217;t work right with SQLite and Rails 0.13.1, while my code seems to be able to generate working sqlite schemas just fine.</p> Thu, 01 Sep 2005 07:07:01 -0700 urn:uuid:136344959ff8e8a6422a6f0aeec04a08 http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-1061 Comment on Auto-generating schema from Rails migrations by topfunky <p>This is really useful. When testing with a team, it would be really useful to be able to generate this so both a complete schema and incremental changes can be generated.</p> Thu, 01 Sep 2005 08:29:41 -0700 urn:uuid:83ef71aba5d977d3ad504a44092b53a7 http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-900 Comment on Auto-generating schema from Rails migrations by Bob Aman <p>Yeah. Originally, when I wrote my FeedTools library, I tried to avoid having db files because it was packaged as a gem and I didn&#8217;t want the user to have to worry about it, but I&#8217;m wondering now if that wasn&#8217;t a mistake.</p> Thu, 01 Sep 2005 08:43:04 -0700 urn:uuid:87eb795e42e070c7cad93bf987a299be http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-1648 Comment on Auto-generating schema from Rails migrations by PhilThompson <p>If you have a table whose data is unlikely to change (for example a states table where the data might be stopped,started, on hold,completed etc) what&#8217;s the best way to populate this table? I would say it makes sense to put it in with the table creation in the migration file but I&#8217;m unsure of the syntax.</p> Sat, 24 Dec 2005 06:32:51 -0800 urn:uuid:b2e022dfb1330c5e46f252228d11826f http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-991 Comment on Auto-generating schema from Rails migrations by PhilThompson <p>Sorry being a numpty. If I&#8217;d read this article properly I&#8217;d have seen how to do it.</p> Sat, 24 Dec 2005 06:49:17 -0800 urn:uuid:4097b608ccb265db567326d81c67117d http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-857 Comment on Auto-generating schema from Rails migrations by PhilThompson <p>Ok, now I&#8217;ve hit an interesting problem (sorry if this is a little off-topic but as I&#8217;ve started&#8230;:). I want to test that the base data that got inserted in the migration is there but it seems all data is removed in the test environment. Well I knew this but I was hoping migrations would get around that but now I mention it I can see why not. This is for manipulating production data and the test only clone the dev schema and not the data. It poses an interesting (slighty) problem. It would be nice to run some tests on a production database to ensure the migration went as planned (obviously without removing the data).</p> Sat, 24 Dec 2005 07:12:03 -0800 urn:uuid:00c30abf8a45d59869ffff601e76b076 http://scottstuff.net/blog/2005/09/01/auto-generating-schema-from-rails-migrations#comment-994