Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the database schema for the Quartz scheduler with Spring Boot and Flyway?

I have a Spring Boot application that uses the Quartz scheduler with a PostGreSQL databse as storage. I'm migrating it from running with it's own db with the public schema to running against a shared db with one schema per application. The schema is managed with flyway.

During testing (with testcontainers) startup of the application fails with

Caused by: org.postgresql.util.PSQLException: ERROR: relation "qrtz_locks" does not exist
  Position: 15

although flyway has previously created that table in the schema app_test_hub_scheduler_v0.

Config is

spring:
  jpa.properties:
    hibernate.default_schema: app_test_hub_scheduler_v0
  flyway:
    enabled: true
    schemas: app_test_hub_scheduler_v0
  jpa:
    properties:
      hibernate:
        default_schema: app_test_hub_scheduler_v0
  quartz:
    jdbc:
      schema: app_test_hub_scheduler_v0
jdbcUrlParams: ?currentSchema=app_test_hub_scheduler_v0

The quartz properties are

org.quartz.scheduler.instanceName=test-hub-scheduler
org.quartz.scheduler.instanceId=AUTO
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=50
org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.useProperties=true
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=qrtz_
org.quartz.jobStore.isClustered=false

It seems quartz doesn't get the schema name. How do I set it?

like image 246
Martin Schröder Avatar asked Oct 25 '25 02:10

Martin Schröder


1 Answers

Quartz scheduler can take the schema_name in account if the following property is declared in the quartz.properties.For example

org.quartz.jobStore.tablePrefix=app_test_hub_scheduler_v0.qrtz_

Here

app_test_hub_scheduler_v0 = is schema name and
qrtz_= is quartz table prefix
like image 164
user06062019 Avatar answered Oct 27 '25 16:10

user06062019