Reputation: 10400
My Environment -> Ruby 1.9.2 and Rails v3.0.5
I noted a strange pattern in rake db:reset. According to rails source code, rake db:reset will => db:drop, db:create and db:migrate. https://github.com/rails/rails/blob/v3.0.5/activerecord/lib/active_record/railties/databases.rake#L159
Setup: One of my migration files have Model.create statements to populate some data (Forgive me, I'm not the one who had put data-filling-code in those migrations :) ..)
Case 1: When I do the steps manually, i mean drop, create, and migrate, one by one - those statements fill data in the table.
Case 2: When I do just rake db:reset, schema is set properly. but the data is not entering the db. Does db:reset skip create/update statements.. I have tried this several times to make sure that I have no faults in the steps I do. I still get this behavior.
what is going wrong here... ?
Upvotes: 4
Views: 2041
Reputation: 103
I had the same problem before but I was running 3.0.3, and it turns out, somehow I manage to mess up the migrations by change the migrations files and not running the migrations(forgot about it or something)...I'll start by checking those files
Upvotes: 0
Reputation: 47578
I think you're reading the wrong line in the source. As I read it:
db:migrate:reset
# => [:drop, :create, :migrate]
db:reset
# => [:drop, :setup]
So db:reset
just create the tables and sets the migrations as if they had been run, without actually running them. db:migrate:reset
actually runs each migration.
Upvotes: 13