mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-08 14:04:52 +03:00
Prevent postgres connection from dropping all at ones
This commit is contained in:
parent
68b526d176
commit
267336d5e7
|
@ -42,20 +42,6 @@ export PGUSER="${POSTGRES_USER}"
|
|||
export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
export PGDATABASE="${POSTGRES_DB}"
|
||||
|
||||
message_info "Dropping all connections to the database..."
|
||||
# Source: http://dba.stackexchange.com/a/11895
|
||||
drop_postgres_connections_sql='UPDATE pg_database'
|
||||
drop_postgres_connections_sql+=" SET datallowconn = 'false'"
|
||||
drop_postgres_connections_sql+=" WHERE datname = '${POSTGRES_DB}';"
|
||||
drop_postgres_connections_sql+='SELECT pg_terminate_backend(pid)'
|
||||
drop_postgres_connections_sql+=' FROM pg_stat_activity'
|
||||
drop_postgres_connections_sql+=" WHERE datname = '${POSTGRES_DB}';"
|
||||
psql \
|
||||
--host=localhost \
|
||||
--username=postgres \
|
||||
--dbname=postgres \
|
||||
--command="${drop_postgres_connections_sql}"
|
||||
|
||||
message_info "Dropping the database..."
|
||||
dropdb "${PGDATABASE}"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user