> But... for me to be using static scaffolds, I _already have_ a
> products table. This migration code will actually fail when I type
> 'rake migrate' , leaving me in an inconsistent state.

I agree that's a catch-22. But the broken part is not migrations, but
rather scaffolding. So let's think about how we can fix scaffolding in
a way that it doesn't require the database to exist before running.
Even before this, I've been burned by scaffolding requiring the
database to be in place before it would run. The only reason this
haven't been fixed yet is probably that most of core doesn't do
script/generate scaffold all that much.

The auto-migration feature is really nice in a non-scaffolding
workflow, though. The way I use and work with a Rails application is
by creating one model at the time as they're needed to make the
application work.

So with a shop, I'd start by creating the product model, making it
work, and then moving on to the cart or the order, and every step of
the way making it all work. This is in contrast to, say, creating the
entire schema first, then starting to work on the model or the
controller.

And that's why the current scaffolding approach is broken. It assumes
that I create my database first while the new model of migrations
encourage a concurrent approach.

>But, no, that doesn't work either, as the scaffold generator
> blows up if the table isn't there.

Yup, current scaffolding generator is broken.

> (On a tangential note, if the model and scaffold generators _do_ have
> to create migrations, they should really be called
> 'create_tablename', not 'add_tablename', just to be consistent.)

Agree, I'll rename.
--
David Heinemeier Hansson
http://www.loudthinking.com -- Broadcasting Brain
http://www.basecamphq.com   -- Online project management
http://www.backpackit.com   -- Personal information manager
http://www.rubyonrails.com  -- Web-application framework
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to