The schema file located in db/schema.rb
was most likely generated the very last time you ran rake db:migrate
. This is because rake db:migrate
migrates your db through all of the migrations in your db/migrate
folder, and then it calls the db:schema:dump
task, which generates the schema file based on the current state of the database.
For your situation, after you have run ActiveRecord::Migration.drop_table(:foo)
in the rails console, the current state of your database (now, no longer having the table foo
) is not in sync with the schema.rb
file that was generated when you last migrated.
What you want to do at this point is re-dump the schema based on the current state of the database, and you do this by running rake db:schema:dump
. This will take the current state of your database (without the table foo
) and generate your db/schema.rb
file.
For more information on the schema file and its relationship to migrations, I would recommend looking at the Rails Guide on Active Record Migrations: Schema Dumping and You.