Obromios
Obromios

Reputation: 16373

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?

Upvotes: 15

Views: 14038

Answers (2)

Umesh Malhotra
Umesh Malhotra

Reputation: 1047

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

Upvotes: 12

Obromios
Obromios

Reputation: 16373

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

Upvotes: 9

Related Questions