Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using postgres instead of h2 fails on liquibase scripts #3518

Open
esbakker opened this issue Feb 28, 2022 · 0 comments
Open

Using postgres instead of h2 fails on liquibase scripts #3518

esbakker opened this issue Feb 28, 2022 · 0 comments

Comments

@esbakker
Copy link

Describe the bug
I want to use postgres instead of the default h2 database, using the docker images. This doesn't work however.
First the connection fails since the default jdbc connection resolver returns an invalid url (i.e. jdbc:postgresql://host:port/kapua;schema=public).
After setting the connection resolver to MariaDB, the connection works, but liquibase scripts fails:

15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - =================== KapuaLiquibaseClient Configuration ===================
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |  Liquibase Version: 3.6.3
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |  DB connection info
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |     JDBC URL: jdbc:postgresql://some.cloud.host:5432/kapua?useTimezone=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |     Username: kapua
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |     Password: ******
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |     Schema: public
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |  Timestamp(3) fix info (eclipse/kapua#2889)
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |     Force timestamp fix: false
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - |     Apply timestamp fix: true
15:31:28.807 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - ==========================================
15:31:28.808 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - Running Liquibase scripts...
15:31:29.415 [main] INFO  org.reflections.Reflections - Reflections took 24 ms to scan 14 urls, producing 333 keys and 344 values
15:31:29.504 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient - Executing pre master files...
15:31:29.506 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient -  Master Liquibase files found: 5
15:31:29.508 [main] INFO  o.e.k.c.l.KapuaLiquibaseClient -       Executing liquibase script: /tmp/kapua-liquibase/changelog-authorization-master.pre.xml...
15:31:31.187 [main] ERROR liquibase.changelog.ChangeSet - Change Set KapuaDB/changelog-authorization-0.2.0.xml::changelog-authorization-domain-0.2.0::eurotech failed.  Error: ERROR: syntax error at or near "("
  Position: 49 [Failed SQL: CREATE TABLE public.athz_domain (scope_id BIGINT(21) unsigned, id BIGSERIAL NOT NULL, created_on TIMESTAMP(3) WITHOUT TIME ZONE DEFAULT NOW() NOT NULL, created_by BIGINT(21) unsigned NOT NULL, name VARCHAR(255) NOT NULL, "serviceName" VARCHAR(1023) NOT NULL, CONSTRAINT ATHZ_DOMAIN_PKEY PRIMARY KEY (id), UNIQUE (name))]
15:31:31.200 [main] ERROR o.e.k.c.l.KapuaLiquibaseClient - Running Liquibase scripts... ERROR! Error: Migration failed for change set KapuaDB/changelog-authorization-0.2.0.xml::changelog-authorization-domain-0.2.0::eurotech:
     Reason: liquibase.exception.DatabaseException: ERROR: syntax error at or near "("
  Position: 49 [Failed SQL: CREATE TABLE public.athz_domain (scope_id BIGINT(21) unsigned, id BIGSERIAL NOT NULL, created_on TIMESTAMP(3) WITHOUT TIME ZONE DEFAULT NOW() NOT NULL, created_by BIGINT(21) unsigned NOT NULL, name VARCHAR(255) NOT NULL, "serviceName" VARCHAR(1023) NOT NULL, CONSTRAINT ATHZ_DOMAIN_PKEY PRIMARY KEY (id), UNIQUE (name))]
liquibase.exception.MigrationFailedException: Migration failed for change set KapuaDB/changelog-authorization-0.2.0.xml::changelog-authorization-domain-0.2.0::eurotech:
     Reason: liquibase.exception.DatabaseException: ERROR: syntax error at or near "("
  Position: 49 [Failed SQL: CREATE TABLE public.athz_domain (scope_id BIGINT(21) unsigned, id BIGSERIAL NOT NULL, created_on TIMESTAMP(3) WITHOUT TIME ZONE DEFAULT NOW() NOT NULL, created_by BIGINT(21) unsigned NOT NULL, name VARCHAR(255) NOT NULL, "serviceName" VARCHAR(1023) NOT NULL, CONSTRAINT ATHZ_DOMAIN_PKEY PRIMARY KEY (id), UNIQUE (name))]

The BIGINT(21) is not supported by postgres

To Reproduce

  1. Add the postgres jdbc driver to the docker image
  2. Configure all commons.db properties (and env variables) for connecting with a postgres database.
    For me that is:
commons.db.connection.host=some.cloud.host
commons.db.connection.port=5432
commons.db.connection.scheme=jdbc:postgresql
commons.db.jdbc.driver=org.postgresql.Driver
commons.db.name=kapua
commons.db.username=kapua
commons.db.password=password
commons.db.schema=public

SQL_SERVICE_HOST=some.cloud.host
COMMONS_DB_SCHEMA=public
  1. Start the application (api, broker or console)
  2. Application can't connect with db since the jdbc url is wrong. Set commons.db.jdbcConnectionUrlResolver to MariaDB
  3. Restart application

Expected behavior
Application starts without issues and creates the correct tables

Version of Kapua
1.5.4

Type of deployment
[ ] Docker
[X] Openshift (in its variants)
[ ] Others

Main component affected
[X] Console (in case of console please report info on which browser you encountered the problem)
[X] REST API
[X] Message Broker
[ ] - Others

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant