Forum: Ruby on Rails New to rails, looking for some advice re: migrations

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
8a06d940b20d983af0e6500f865b5e54?d=identicon&s=25 Eric Nielsen (Guest)
on 2006-05-22 06:11
I'm trying to get started with Rails, but I'm running into a few places
where I'm having trouble understanding the expected workflow.

I'm trying to work with migrations from the beginner; its a port of an
existing application, but I'd like to let the db schema evolve as the
application grows, so I'm starting from an empty (tableless) database.

If I generate a migration, I can fill in the up/down methods and start
creating a table; rake migrate ran fan.  However when I then generate a
model it seems to create another migration automatically that is named
appropriately for the eariler self-created migration.  This seemed odd,
so I thought I did something against the expected way.  As I hadn't done
anything, I wiped the DB and the rails project and recreated both.  This
time I tried generating a scaffolding first, thinking that it would
create the first migration that I would then fill in and get things
rolling from there.  This generated the "before updating scaffolding
from a new DB schema..." error.  (Which makes sense to me now that I
think about it.)

Can anyone help me out and explain what the "expected" order of
"generate foos" are when starting from a completely blank slate if I
want to do things the "rails"-way?  (I would prefer to use migrations as
opposed to creating the ddl manually, as long as that preference isn't
at odds with normal rails practices)

Also, am I correct that the only way to "back-out" a script/generate foo
is to rollback via version control?

Thank you.
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-05-22 06:44
(Received via mailing list)
On Monday, May 22, 2006, at 6:11 AM, Eric Nielsen wrote:
>appropriately for the eariler self-created migration.  This seemed odd,
>want to do things the "rails"-way?  (I would prefer to use migrations as
>Rails mailing list

There are a few things about the generators that are a bit odd.  Here's
the process I use.

1. generate the model.  this generates a migration file, which I then
fill out with the appropriate fields and foreign keys.

2. rake migrate

3. generate the scaffold, ignore/delete any migration files it may

4. lather, rinse, repeat.

You can undo a 'script/generate foo' with a 'script/destroy foo'.

This topic is locked and can not be replied to.