"xxxxx_development" is being accessed by other usersエラー
bin/rails db:migrate:reset
PG::ObjectInUse: ERROR: database "xxxxx_development" is being accessed by other users
DETAIL: There are 2 other sessions using the database.
: DROP DATABASE IF EXISTS "xxxxx_development"
Couldn't drop database 'xxxxx_development'
psql -l //データベース名を確認
psql postgres //postgreSQLにログイン
\du //ユーザーと権限を確認
#この場合、接続中のユーザセッションを強制的に切断後に再実行します。
#まずは、接続中のユーザのpidを以下のコマンドで求めます。
postgres=# SELECT pid FROM pg_stat_activity where pid <> pg_backend_pid();
pid
-------
82450
82454
21658
(3 rows)
#接続中のユーザセッションを強制的に切断する
postgres=# SELECT pg_terminate_backend(82450);
pg_terminate_backend
----------------------
t
(1 row)
postgres=# SELECT pg_terminate_backend(82454);
pg_terminate_backend
----------------------
t
(1 row)
postgres=# SELECT pg_terminate_backend(21658);
pg_terminate_backend
----------------------
t
(1 row)
#抜ける
postgres=# \q
正常に動いた!