Using rake db: migration inside another task leaves pending migrations

I am new to rake and I am trying to find a way to automate some tasks. So I wrote my first rake task and couldn't:

namespace :app do
  desc "Leaves application like new"
  task :reset => :environment do
    Rake::Task['db:drop:all'].invoke
    Rake::Task['db:create:all'].invoke
    Rake::Task['db:migrate'].invoke
    Rake::Task['db:seed'].invoke
  end
end

I would like to know why this is not working. After the call:

rake app:reset

everything works fine, I see migration messages on the screen, for example:

==  CreateGalerias: migrating =================================================
-- create_table(:galerias)
NOTICE:  CREATE TABLE will create implicit sequence "galerias_id_seq" for serial column "galerias.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "galerias_pkey" for table "galerias"
   -> 0.1191s
==  CreateGalerias: migrated (0.1194s) ========================================

But in the end I get this message:

You have 11 pending migrations:
  20110704052637 CreatePersonas
  20110709100632 CreateOrganizaciones
  20110709100646 CreateEventos
  20110816102451 CreateMembresias
  20110816155851 CreateCelebraciones
  20110822135820 ActsAsTaggableOnMigration
  20120410063100 CreateDocumentos
  20120507200516 CreateUsuarios
  20120515214226 ActivaUnnaccent
  20120516091228 CreateGalerias
  20120517004708 SetupHstore
Run `rake db:migrate` to update your database then try again.

Didn't he just move the database? why is he complaining about this?

+5
source share
1 answer

, db: drop: all db: create: , db: migrate db: seed , , , . db: drop: all to db: drop db: create: all to db: create , , :

rake RAILS_ENV=production app:reset
+2

All Articles