ruby - Rails editing migration to ignore an error -


i have app posts, users, tags , such. i've been working on locally , have not been able push heroku because of issue. in end, succeeded in pushing app heroku, realised never migrated database there. ran

heroku run rake db:migrate 

and got error:

== 20141116151429 createposts: migrating ====================================== -- drop_table(:posts) pg::undefinedtable: error:  table "posts" not exist : drop table "posts" rake aborted! standarderror: error has occurred, , later migrations canceled:  pg::undefinedtable: error:  table "posts" not exist 

i looked migration , reason, had drop tables line before else:

class createposts < activerecord::migration   def change     drop_table :posts     create_table :posts |t|       t.string :title,              null: false, default: ""       t.text :description, null: false, default: ""        t.timestamps     end   end end 

i commented out drop table line, deleted , commit using git commit, tried run heroku rake db:migrate, error still shows. know serious muck up, don't know here.

i have not tried resetting databse fear of might go wrong, although can, technically, lose posts/users/comments , such have created far.

is there way can remedy , still push database data heroku? if not, should app running in first place?

edit:

i changed migration be:

class createposts < activerecord::migration   def     create_table :posts |t|       t.string :title,              null: false, default: ""       t.text :description, null: false, default: ""        t.timestamps     end   end    def down     drop_table :posts   end end 

but error still shows. don't understand: know edited right file (20141116151429_create_posts.rb) , removed line. changed entire contents of , commit these changes, running heroku rake db:migrate still comes drop_tables error.

from understand, isn't heroku rake db:migrate pretty same rake db:migrate? if so, should run migrations pending. in case, of them are, i've never migrated heroku. if so, change make migration file hasnt been run should reflected. , yet getting error.

it should work when comment out drop_table syntax. if not working try use below syntax.

it run drop_table when table exist in database.

class createposts < activerecord::migration   def change     drop_table 'posts' if activerecord::base.connection.table_exists? 'posts'     create_table :posts |t|       t.string :title,              null: false, default: ""       t.text :description, null: false, default: ""        t.timestamps     end   end end 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -