Rolling back a migration in Ruby on Rails -


i working on first ruby on rails project, , have created "users" table app using "rails generate scaffold users" command.

now trying undo statement wish try rewrite classes involved class , table in database.

i saw scaffold statement created "def change" class in migration, , when try rollback migration there no function within migration. added "def down" method "drop_table :users" defined within it.

def down     drop_table :users end 

however, when run "rake db:rollback", there no response in command prompt , table unchanged.

i not quite sure how undo migration rewrite table schema. can offer assistance please?

the whole migration looks following:

class createusers < activerecord::migration     def change         create_table :users |t|             t.string :name             t.string :password_digest             t.string :email              t.timestamps         end     end      def down         drop_table :users     end end 

edit: fixed running db:drop , db:rollback clear schema. think there issue me having database open in program. closed , allowed database rolled back.

rails generate scaffold users doesn't change database, generate mvc code. can undo destroy scaffold command

 rails destroy scaffold users 

if run rake db:migrate command can rollback rake db:rollback command. @ migration file, change method enough create or drop operation of tables. no down method needed, down method complement method of up method.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -