Open pgadmin / dbeaver and establish connection to just created database
Try to re-create database again "gradlew createDb"
Expected: informative error message
Actual:
> Task :app-core:createDb
Using database URL: jdbc:postgresql://localhost/postgres, user: root
Executing SQL: drop database if exists "sales";
[ant:sql] Failed to execute: drop database if exists "sales"
org.postgresql.util.PSQLException: ERROR: database "sales" is being accessed by other users
Detail: There are 2 other sessions using the database.
Executing SQL: create database "sales" with template=template0 encoding='UTF8';
[ant:sql] Failed to execute: create database "sales" with template=template0 encoding='UTF8'
> Task :app-core:createDb FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app-core:createDb'.
> org.postgresql.util.PSQLException: ERROR: database "sales" already exists
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
2 actionable tasks: 1 executed, 1 up-to-date
ERROR: database "sales" already exists
19:02:37: Task execution finished 'createDb'.
Why we are trying to run "create database" statement after "drop if exists" has failed?
It makes no sense, at least for postgres, and leads to misleading error messages like "ERROR: database "sales" already exists".
Environment
Description of the bug or enhancement
Expected: informative error message Actual:
Why we are trying to run "create database" statement after "drop if exists" has failed? It makes no sense, at least for postgres, and leads to misleading error messages like "ERROR: database "sales" already exists".