Ошибка:
ERROR: database "database_name" is being accessed by other users DETAIL: There is 1 other session using the database.
Решение:
REVOKE CONNECT ON DATABASE database_name FROM public;
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'database_name';