Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I cancel a running migration?

In a Ruby On Rails app I ran rails db:migrate, and for some reason the migration hung. I ended up having to kill the terminal tab in which the migration was run. When I tried to run rails db:migrate in a new tab, I received this error message:

Cannot run migrations because another migration process is currently running

How do I fix this?

like image 521
Obromios Avatar asked Apr 23 '17 07:04

Obromios


2 Answers

If you are using postgresql in linux based system, you can use below command to restart the database. Then run your migrations again.

/etc/init.d/postgresql restart
like image 172
Umesh Malhotra Avatar answered Nov 16 '22 16:11

Umesh Malhotra


Stop and then restart the database again. Then try rails db:migrate again.

If you are using posgresql installed with homebrew on Mac OSX the following stops/restarts the database:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
pg_ctl -D /usr/local/var/postgres stop -s -m fast
like image 36
Obromios Avatar answered Nov 16 '22 16:11

Obromios