Failing to install Crowd on PostgreSQL 9.6
Asked by Matthias Kannenberg:

I'm trying to install Crowd with a PostgreSQL but running always into the same issue. While the database tables are created I get the following error:

```
INFO http-nio-8095-exec-11 INFO [liquibase] ChangeSet liquibase/bootstrap/22_cwd_synchronisation_status.xml::KRAK-707: cwd_synchronisation_status::crowd ran successfully in 59ms
ERROR http-nio-8095-exec-11 ERROR [liquibase] Change Set liquibase/bootstrap/22_cwd_synchronisation_status.xml::KRAK-707: cwd_synchronisation_status - name foreign key::crowd failed. Error: ERROR: constraint "fk_clce0lxxnu12qkiwf3xu5iody" of relation "cwd_synchronisation_status" does not exist
Location: File: tablecmds.c, Routine: ATExecDropConstraint, Line: 7805
Server SQLState: 42704 [Failed SQL: ALTER TABLE crowd.cwd_synchronisation_status DROP CONSTRAINT fk_clce0lxxnu12qkiwf3xu5iody]
INFO http-nio-8095-exec-11 INFO [liquibase] Successfully released change log lock
ERROR http-nio-8095-exec-11 ERROR [console.action.setup.Database] Database configuration failed. liquibase.exception.MigrationFailedException: Migration failed for change set liquibase/bootstrap/22_cwd_synchronisation_status.xml::KRAK-707: cwd_synchronisation_status - name foreign key::crowd:
Reason: liquibase.exception.DatabaseException: ERROR: constraint "fk_clce0lxxnu12qkiwf3xu5iody" of relation "cwd_synchronisation_status" does not exist
Location: File: tablecmds.c, Routine: ATExecDropConstraint, Line: 7805
Server SQLState: 42704 [Failed SQL: ALTER TABLE crowd.cwd_synchronisation_status DROP CONSTRAINT fk_clce0lxxnu12qkiwf3xu5iody]
java.lang.RuntimeException: liquibase.exception.MigrationFailedException: Migration failed for change set liquibase/bootstrap/22_cwd_synchronisation_status.xml::KRAK-707: cwd_synchronisation_status - name foreign key::crowd:
Reason: liquibase.exception.DatabaseException: ERROR: constraint "fk_clce0lxxnu12qkiwf3xu5iody" of relation "cwd_synchronisation_status" does not exist
Location: File: tablecmds.c, Routine: ATExecDropConstraint, Line: 7805
Server SQLState: 42704 [Failed SQL: ALTER TABLE crowd.cwd_synchronisation_status DROP CONSTRAINT fk_clce0lxxnu12qkiwf3xu5iody]
at com.atlassian.crowd.util.persistence.hibernate.LiquibaseSchemaHelper.runLiquibaseUpdate(LiquibaseSchemaHelper.java:142)
at com.atlassian.crowd.util.persistence.hibernate.LiquibaseSchemaHelper.lambda$updateSchemaIfNeeded$1(LiquibaseSchemaHelper.java:80)
at com.atlassian.crowd.util.persistence.hibernate.LiquibaseSchemaHelper.withServiceRegistry(LiquibaseSchemaHelper.java:166)
at com.atlassian.crowd.util.persistence.hibernate.LiquibaseSchemaHelper.withServiceRegistry(LiquibaseSchemaHelper.java:152)
```

Here is what I tried:

* Multiple times with fresh installations of both Crowd and the DB
* Crowd 3.4.3 and 3.4.4
* PostgreSQL 10 and 9.6.
* PostgreSQL Dialects: PostgreSQL94Dialect, PostgreSQL9Dialect and PostgreSQLDialect
* Using a seperate crowd schema and the public schema


Answers:
author: Matthias Kannenberg
body: I finally found the answer:

Atlassian tools do not officially support using schemas in PostgreSQL and while you can circumvent this by adding "?currentSchema=yourschema" to the end of the JDBC connection string (or if you do not have a connection string to the end of the database name) and all tools will install in the schemas you give them, there seems to still be some black magic going on.

My initial though process was that Crowd really does not like installing in a separate schema but even an installation to the standard public schema failed with the same issues.

Turns out that I installed Jira and Confluence beforehand in their respective schemas and naivly thought that this would not affect installations in other schemas but it actually caused problems with both Bitbucket and Crowd (different SQL issues but ultimately failed installations).

The only installation order I found that works and does not fail on the database setup stage for all tools:

1. Bitbucket
2. Crowd
3. Jira
4. Confluence
5. Bamboo

I'm still a bit on the fence about Jira and Bamboo because while installation did succeed and I have not yet seen any apparent visible issues I do sometimes see errors related to missing relations in the logs.


Tags: crowd-administration

postgres