jeudi 15 juin 2017

Liquibase + Postgres - Tests are failing when functions are present in changelog

I'm having some problems with functions using postgresql + liquibase

When I compile my project with mvn clean install and runs the tests, one test is failing.

Results :

Tests in error: 
  LiquibaseH2IT.testH2AllContexts:74 » BeanCreation Error creating bean with nam...

It doesn't give the name of the bean that fails. The only solution so far is removing the postgresql functions I have defined in the liquibase changelog.

If I skip the tests, it builds with no problem, but I had to make a workaround to make the functions work, importing them as a changeset like this:

<changeSet author="lukespringwalker" id="params">
    <sqlFile path="migration/migration-params.sql" splitStatements="false"/>
</changeSet>

So far I couldn't find any solution and I start thinking that it doesn't support functions (I read somewhere that h2 has to support all statements).

Here is one of the functions defined in migration-params.sql:

--changeset lukespring:params-01 dbms:postgresql,h2
DO
$OutOfBalanceTillEnabled$
BEGIN
IF (select count(*) from param_definition where name = 'OutOfBalanceTillEnabled') > 1 THEN
  DELETE FROM list_param WHERE opt_id IN (SELECT id FROM list_param_option WHERE def_id = (SELECT MAX(id) FROM param_definition WHERE name = 'OutOfBalanceTillEnabled'));
ELSE 
END IF;
END
$OutOfBalanceTillEnabled$;

Thanks!

Aucun commentaire:

Enregistrer un commentaire