[ 
https://issues.apache.org/jira/browse/FINERACT-2099?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Adam Saghy updated FINERACT-2099:
---------------------------------
    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);
    }
 
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
select table_name, count(table_name) from information_schema.tables where 
table_schema = 'public' and table_name = 'databasechangelog' group by table_name
{panel:title=Acceptance criteria}
 - Initial liquibase which creates the liquibase tables to be executed only 
once!{panel}

  was:
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



{panel:title=Acceptance criteria}
- Initial liquibase which creates the liquibase tables to be executed only once!
{panel}


> Initial Liquibase got executed every execution
> ----------------------------------------------
>
>                 Key: FINERACT-2099
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2099
>             Project: Apache Fineract
>          Issue Type: Bug
>    Affects Versions: 1.10.0
>            Reporter: Adam Saghy
>            Priority: Major
>             Fix For: 1.11
>
>
> * 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);
>     }
>  
> 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
> select table_name, count(table_name) from information_schema.tables where 
> table_schema = 'public' and table_name = 'databasechangelog' group by 
> table_name
> {panel:title=Acceptance criteria}
>  - Initial liquibase which creates the liquibase tables to be executed only 
> once!{panel}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to