How to ask spring to create corresponding schema for JdbcMetadataStore?

792 views Asked by At

I want to use jdbc metadata store which described here: https://docs.spring.io/spring-integration/docs/5.2.0.BUILD-SNAPSHOT/reference/html/jdbc.html#jdbc-metadata-store

quote:

The org.springframework.integration.jdbc package has Database schema scripts for several RDMBS vendors. For example, the following listing shows the H2 DDL for the metadata table:

CREATE TABLE INT_METADATA_STORE  (
    METADATA_KEY VARCHAR(255) NOT NULL,
    METADATA_VALUE VARCHAR(4000),
    REGION VARCHAR(100) NOT NULL,
    constraint INT_METADATA_STORE_PK primary key (METADATA_KEY, REGION)
);

I've found schema for my postgresql in the jar file. Sure I could just copy this schema and run in the pgAdmin once but I want to ask spring to check that my current schema exist and if not - create corresponding schema from the jar file.

How can I cahieve it ?

P.S.

Also in my project I use schema auto-generation based on beans(Entities) definitions so spring.jpa.hibernate.ddl-auto = none + copying schema from jar to local shema.sql is not an option

1

There are 1 answers

1
Artem Bilan On BEST ANSWER

The spring.jpa.hibernate.ddl-auto is fully not related to Spring Integration JDBC support. That one is for JPA and is done really different way than shema.sql.

Actually those mentioned scripts in org.springframework.integration.jdbc package are auto-scanned by Spring Boot and an appropriate schema is populated in the data base.

See respective Spring Boot documentation: https://docs.spring.io/spring-boot/docs/2.2.2.RELEASE/reference/html/spring-boot-features.html#boot-features-integration

So, the option spring.integration.jdbc.initialize-schema=always should make your day and fully does not effect any other possible options.