db:migrate:redo leaves schema.rb in incorrect state #5030

Closed
jleven opened this Issue Feb 13, 2012 · 2 comments

Comments

Projects
None yet
3 participants

jleven commented Feb 13, 2012

The rake task db:migrate:redo is implemented as:

    task :redo => [:environment, :load_config] do
      if ENV['VERSION']
        db_namespace['migrate:down'].invoke
        db_namespace['migrate:up'].invoke
      else
        db_namespace['rollback'].invoke
        db_namespace['migrate'].invoke
      end
    end

Each of these rake tasks invokes db_namespace['_dump'].invoke but because these are rake tasks, only the first invocation is executed. This leaves the schema.rb file in the state between the rollback and migrate (or between the down and up).

A simple fix would be to have each of these tasks call db_namespace['_dump'].execute to ensure the _dump task is always invoked.

I've already noticed this in two different test applications here, I confirm this is an issue, but I still couldn't take a look on how to fix it though. Thanks for your input.

@carlosantoniodasilva carlosantoniodasilva added a commit to carlosantoniodasilva/rails that referenced this issue Feb 14, 2012

@carlosantoniodasilva carlosantoniodasilva Always reenable _dump task in AR databases rake. Closes #5030
This allows the internal :_dump task to be called as many times as
required. For instance, `rake db:migrate:redo` calls two tasks that
internally call :_dump, and without reenabling it to be reinvoked,
the database was left in incorrect state.
4b44c20

josevalim closed this in abdff44 Feb 14, 2012

jleven commented Feb 14, 2012

Thanks @carlosantoniodasilva, nice fix.

@arunagw arunagw pushed a commit to arunagw/rails that referenced this issue Feb 16, 2012

@josevalim @josevalim josevalim + josevalim Merge pull request #5038 from carlosantoniodasilva/fix-db-migrate-redo
Always reenable _dump task in AR databases rake. Closes #5030
5f9a5a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment