Home how can i rollback on ruby on rais in my situation
Reply: 3

how can i rollback on ruby on rais in my situation

Menphis Published in 2018-02-14 04:49:28Z

I need to rollback migration on my ruby on rails project

I accidently deleted my migration file, [ID:20180214033313].

my migration status

migration output

I tried doing bundle exec rake:db rollback but it didn't help and I also tried bundle exec rake db:migrate:down VERSION=20180214033313 but it gave me the error below,

No migration with version number 20180214033313> 

Any suggestions on how can I fix this?

Ruturaj Bisure
Ruturaj Bisure Reply to 2018-02-14 07:03:30Z
  1. If you are using git then, You can use git to recover that file, In git status (or git gui) where you will find the list of changed files, There you will see

    deleted: db/seeds.rb

    something like this for deleted files. Just use,

    git checkout filename

    And it will restore file.

  2. If you are not using git then, use rake db:migrate:status and check the timestamp and create a file with exact same timestamp of deleted file and the name which you had given earlier. And add the same code like before. And do migrate.

Hope this will help

Thananjaya Reply to 2018-02-14 07:13:20Z

Better Solutions for your situation.Assuming you have git initialised with your application,

If you deleted your migration in current commit

Execute git stash so that you can terminate/delete the changes you made. Now You can rollback the migrations.

If you deleted your migration in previous commit

You can drop your database by using the command DROP DATABASE databasename and you can make fresh migration.

user3349825 Reply to 2018-02-14 07:23:18Z

If you're using the github app for desktop, you can simply right click and discard the changes you've made.

I've done the same thing before it's a real simple rollback

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.331604 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO