cuba-platform / cuba-gradle-plugin

Gradle plugin for building CUBA platform and applications
https://www.cuba-platform.com
Apache License 2.0
15 stars 18 forks source link

Do not create DB when its deletion failed #115

Closed dtsaryov closed 4 years ago

dtsaryov commented 5 years ago

Environment

Description of the bug or enhancement

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".

dtsaryov commented 5 years ago

Fixed in commit: f3042a