Ruby on Rails Saturday, February 1, 2014

Hi,

I accidentally created a model with "rails generate model Category" (also creating migrate file) where I didn't specify any fields. Then I run rake db:migrate to create the new table. Upon realising what I'd done, I run "rails destroy model Category". Then I run "rails generate model Category name:string user_id:integer" which created all the new files. Ofcourse now db:migrate wouldn't work coz I forgot I'd created the category table prior. So, I thought I'd remove the old table and run rake db:reset. This appeared to create all the tales again, but it keeps creating the OLD category table - the one without any fields. I've tried dropping the database, destroying the model/ migrate files, rolling back the migration, db:shema:load/ db:create:all/ . But every time, even if there is no "create category table" migrate file - it still creates the category table with no fields.

Is this normal? I don't know where it's getting the schema from but it can't be reading only from my db:migrate files. Does it get them from log files when recreating the db, or does it look directly at the db and rebuild. I want my database build purely from the files I'm looking at in my db/migrate folder. How do I do this?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a75dd279-edf7-4c71-a3b2-9987678f7b33%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment