Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10431 (closed enhancement: fixed)

Opened 9 months ago

Last modified 9 months ago

[PATCH] add a simple way of remigrating the last migration (or more)

Reported by: matt Assigned to: daivd
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: db:reset db:redo migrations database
Cc:

Description

This rake task is meant to be used maily in development and testing environment. Let's say you are working on your migration, generated a first version and realized that you want to modify your DB schema still a little more. Since you didn't commit your code, you probably don't want to create yet another migration. So you edit your latest migration file.

But how do you get your db to be in sync with the migrations files? rake db:reset uses the schema.rb file, so you can't do that.

This is when rake db:redo becomes super useful. rake db:redo simply rollbacks your database one step (or whatever amount of step you passed to the task using the STEP constant) and migrate up your database.

This might not be always working since migrating down might not work. That's why I have another patch to add rake migrations:reset.

Attachments

rake_db_redo.diff (0.7 kB) - added by matt on 12/09/07 09:23:19.
rake db:redo

Change History

12/09/07 09:23:19 changed by matt

  • attachment rake_db_redo.diff added.

rake db:redo

12/09/07 09:27:44 changed by matt

see #10432 ( http://dev.rubyonrails.org/ticket/10432 ) for rake migrations:reset

12/09/07 13:24:38 changed by chuyeow

  • summary changed from add a simple way of remigrating the last migration (or more) to [PATCH] add a simple way of remigrating the last migration (or more).

+1. This would be very useful (if combined with your other patch) when creating migrations during development, since I almost always get things wrong the first time round.

Nitpick: for consistency with the task descriptions for the other tasks, can the task description read more like:

Rolls the schema back to the previous version and re-runs the last migration. If you want to rollback more than one step, specify STEP=n.

I'd love if you could attempt to keep the number of rollbacks and migrations the same (since theoretically you could now step back 1 migration and be migrated up 3 migrations, depending on what migration files you have).

12/10/07 13:46:24 changed by cch1

+1

Excellent! I'll be using this 100 times a day during the modeling phase of my projects.

Is it just me or is the rake db namespace getting crowded and inconsistent?

12/14/07 17:48:01 changed by david

  • status changed from new to closed.
  • resolution set to fixed.

(In [8382]) Added db:migrate:redo for rerunning existing migrations (closes #10431) [matt]