Forum: Ruby on Rails rake redo??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mk 2. (Guest)
on 2009-05-21 01:04
Being someone who likes to write code and do everything myself this
rails deal has me grinding my teeth, but I will get over it.

I just noticed after doing a "rake db:migrate" that I mispelled a
method/column name.  So before doing anything else, I corrected the
spelling in the relevant db/migrate .rb file and ran "rake db:migrate"
again hoping that would do.  However, looking in the db/schema.rb file,
nothing had changed.  So I erased that and the database and tried rake
again and hopefully everything is fine BUT that is hackish, to say the
least.

I've only glanced through the rake docs, --help, etc, and can't find
anything pertinent to the issue.  Anyone nice wanna explain quick?

The other part of my question: does rake affect anything outside db/ ?
If not, everything should be hunky dory.

Right?
Frederick C. (Guest)
on 2009-05-21 01:13
(Received via mailing list)
On May 20, 10:04 pm, Mk 27 <removed_email_address@domain.invalid> wrote:
>
rake db:rollback rolls back the last migration you've run

> I've only glanced through the rake docs, --help, etc, and can't find
> anything pertinent to the issue.  Anyone nice wanna explain quick?

rake is a fairly generic ruby tool, so the rake documentation is
unlikely to be helpful. in a given context (eg inside your rails
folder) rake -T will list available tasks. The migrations guide
( http://guides.rubyonrails.org/migrations.html#runn... )
has some more info.
>
> The other part of my question: does rake affect anything outside db/ ?

rake tasks are arbitrary ruby code. in theory you could have a rake
task that launched a missile at the moon. The tasks that rails
provides in the db: namespace do just fiddle with the database (or
related files like schema.rb)

Fred
Colin L. (Guest)
on 2009-05-21 01:13
(Received via mailing list)
If a rake db:migrate succeeds but you realise it is not what you want
then
the thing to do is 'rake db:rollback' which will run the 'down' part of
the
previous migration and so should take you back to where you were.  Then
correct the migration and run it again.

If a migration fails, however, you must manually undo any changes made
before the error, correct the code and migrate again.  Do not do a
rollback
in this case as it will go back to the one before you started, if you
understand me.  At least this is the case on MySQL which does not handle
transactions which include changes to db structure.  I am not sure
whether
the situation is different with other db types.

Colin

2009/5/20 Mk 27 <removed_email_address@domain.invalid>
Mk 2. (Guest)
on 2009-05-21 02:28
Frederick C. wrote:

> rake tasks are arbitrary ruby code. in theory you could have a rake
> task that launched a missile at the moon. The tasks that rails
> provides in the db: namespace do just fiddle with the database (or
> related files like schema.rb)
>
> Fred

Thanks all!
Brendon W. (Guest)
on 2009-05-21 04:11
(Received via mailing list)
Surprised nobody mentioned:
rake db:migrate:redo VERSION=<xxx>

It lets you redo a single migration, don't forget to dump the table
and then reload it if you want to keep the data.

Brendon.
This topic is locked and can not be replied to.