rake db:reset doesn't work, fails with unknown attribute: user_status

If I manually drop the database, and run create, then migrate it works fine.

But doing a:

rake db:reset

it fails with:

unknown attribute: user_status

Does this mean my migrations are not dropping things correctly?

I believe that rake db:reset re-creates the db and loads the schema
from schema.rb rather than running the migrations [1]. Is there
something odd in schema.rb, possibly related to user_status?

[1] http://guides.rubyonrails.org/migrations.html#resetting-the-database


Colin Law wrote in post #1047551:

It would be nice if there was a way to mirror things to RAILS_ENV=test also.

I hate having to do it for both.

First thing to do seems to check with --trace.

$ rake --trace db:reset

and study the order of execution of rake tasks in detail until the

point where it fails …



Why doesn’t rake -T show db:reset? Where can I find a list of these hidden rake commands?

Why doesn’t rake -T show db:reset?

Because the desc is not defined or is commented out.

Where can I find a list of these hidden rake commands?

Checking these files could help you. The migration tasks are

in the first one.

peterv@ASUS:~/b/github/rails/rails$ find . -name ‘*.rake’















As you will see, some tasks have no desc above them,

or the desc is commented out (probably because it is

not intended as a public available command).

E.g. rake db:reset is defined as such:

db_namespace = namespace :db do

desc 'Drops and recreates the database from db/schema.rb for the current env

ironment and loads the seeds.’

task :reset => :environment do





with the desc commented out.

and rake db:migrate:reset as such:

db_namespace = namespace :db do

namespace :migrate do

desc ‘Resets your database using your migrations for the current environment’

task :reset => [‘db:drop’, ‘db:create’, ‘db:migrate’]