Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.10.0
-
None
-
None
Description
TenantDatabaseUpgradeService.java, line 94, calls TenantDatabaseStateVerifier.isFirstLiquibaseMigration()
the implementation checks if the database table called DATABASECHANGELOG exists:
public boolean isFirstLiquibaseMigration(DataSource dataSource) { boolean databaseChangelogTableExists = dbQueryService.isTablePresent(dataSource, "DATABASECHANGELOG"); return !databaseChangelogTableExists; }
the actual check executed here is:
public boolean isTablePresent(DataSource dataSource, String tableName) { return choose(dataSource).isTablePresent(dataSource, tableName); }
and if PostgreSQL is chosen:
public boolean isTablePresent(DataSource dataSource, String tableName) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); Integer result = jdbcTemplate.queryForObject(format("SELECT COUNT(table_name) " + "FROM information_schema.tables " + "WHERE table_schema = 'public' " + "AND table_name = '%s';", tableName), Integer.class); return Objects.equals(result, 1); }
this is an issue - tableName is all uppercase, and in PostgreSQL the following query returns no rows:
select table_name, count(table_name) from information_schema.tables where table_schema = 'public' and table_name = 'DATABASECHANGELOG' group by table_name
while the following query correctly returns 1 row)
select table_name, count(table_name) from information_schema.tables where table_schema = 'public' and table_name = 'databasechangelog' group by table_name
Acceptance criteria
- Initial liquibase which creates the liquibase tables to be executed only once!