totara / totara-docker-dev

A docker setup to create a development environment for Totara Learn
MIT License
49 stars 32 forks source link

Feature improve postgres drop behaviour #178

Closed simoncoggins closed 3 years ago

simoncoggins commented 3 years ago

My workflow is to have a terminal tab open with a postgres shell (via tdb shell) open at all times. However when you run a tdb command that drops a database it fails if there is an existing session.

This PR triggers a postgres statement which will kill any existing sessions allowing the database drop to proceed.

In the session that's been dropped, if you execute another command after the session was killed you get an error:

FATAL:  terminating connection due to administrator command
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.

but then it auto-reconnects and you can just repeat the command from history.