mysql - Can't run a db migration on rails -


i have had ongoing trouble migrating database in rails via rake db:migrate.

my migration looks this:

class createarticles < activerecord::migration   def change     create_table :articles |t|     t.string :title     t.text :subtitle     t.string :slug     t.text :body     t.integer :publish, limit: 1, default: 0     t.timestamps     end   end end 

however if ever delete column or add or modify 1 rake db:migrate command nothing. way can migrate running like:

rake db:migrate version=20080906120000 

but temperamental of time need reset db using

db:drop db:create 

then running migration again normal. db:migrate ever works first time after dropping , creating db.

i've tried rollback before running migration.

this far ideal i'd appreciate help.

(i realise there similar questions of issues solved after db reset)

you need run migration down , run up again, done redo task. try this:

rake db:migrate:redo version=20080906120000 

edit: if have data want keep in table, it's better make new migration remove column or whatever want do, above drop , recreate table, wiping data in process.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -