ruby - rails destroy scaffold leaves back table -
i created new scaffold using command:
rails generate scaffold level
but destroyed using command
rails destroy scaffold level
and again added using command
rails generate scaffold level question:string answer:string prev_q:integer next_q:integer
but when try rake db:migrate following error
sqlite3::sqlexception: table "levels" exists: create table "levels" ("id" integer primary key autoincrement not null, "question" varchar(255), "answer" varchar(255), "prev_q" integer, "next_q" integer, "created_at" datetime not null, "updated_at" datetime not null)
my migrate/create_level.rb is
class createlevels < activerecord::migration def change create_table :levels |t| t.string :question t.string :answer t.integer :prev_q t.integer :next_q t.timestamps end end end
but schema.rb is:
create_table "levels", :force => true |t| t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end
i want know how can update levels table in schema. know why doesn't table deleted when destroy scaffold. need run command it?
using destroy scaffold
not run rollback migration. correct way of doing have been
rake db:rollback rails destroy scaffold level
now, don't have other migration anymore, cannot roll back. you'll need delete table manually:
rails dbconsole drop table levels;
Comments
Post a Comment