Closed midhunadarvin closed 5 months ago
I'm not sure to have got your point. Anyway, if you need to run Quartz with a DB to persist the scheduler config, you don't need to run liquibase and switch spring.quartz.initialize-schema
to always
and later to never
again. Simply you have to import the quartz-manager-starter-persistence
dependency in your project. That dependency will run liquibase at the bootstrap to initialize the tables, only once, at the first bootstrap.
See this paragraph
Is it what you were looking for?
I did try the same to bootstrap a newly created database with the scheduler configs. I used the docker-compose file in the quartz-manager-web-showcase
project to create a new postgres container. I added the quartz-manager-starter-persistence
as dependency. In application.yml
, the database url, username, password are given. However when I started the quartz-manager-web-showcase
project the qrtz_*
tables were not created.
I think why it doesn't work is because spring.quartz.initialize-schema
is set to never
in the quartz-persistence.properties
When i set this property to always
, the tables are initialized, but I could see stack overflow links where when we set spring.quartz.initialize-schema
to always
, the tables are dropped and created again on every restart of the application.
https://stackoverflow.com/questions/64101847/spring-boot-quartz-jdbc-tables-are-always-initailized
Is there anything that i might have missed ?
You've got a bug.
spring.quartz.initialize-schema
is set to never
in the quartz-persistence.properties
, because quartz-manager-starter-persistence
has the quartz DB scripts within it and it should execute them through liquibase, at the bootstrap.
Unfortunately, liquibase isn't finding the changelog, thus quartz DB scripts are not executed.
Thank you to have notified it.
I'm debugging...
Hi @midhunadarvin, I've just fixed. I've released the ver 4.0.9 with this fix and your already merged contributions.
I confirm that it's enough to import the dependency quartz-manager-starter-persistence
to get initialized the tables.
You can get an example here: https://github.com/fabioformosa/quartz-manager-use-cases/tree/main/with-persistence
Thanks @fabioformosa . I checked it and confirm that it is working. Closing this issue.
Hi,
I had a requirement of setting up quartz with persistence in a postgres database. With the quartz-manager project if I have to initialize the database, I could set the
spring.quartz.initialize-schema
fromnever
toalways
This will help initialize the database, but it will drop existing tables and initialize on every startup of the application. So in order to workaround that, the 1st deployment should be with the property
spring.quartz.initialize-schema=always
and the 2nd deployment should be with the propertyspring.quartz.initialize-schema=never
This will work but doesn't seem clean due to dependency on multiple deployment.
I tried to setup the
quartz-manager-starter-persistence
project with configuration to run it independently and initialize the database without the need for spring boot project to start.In pom.xml of
quartz-manager-starter-persistence
liquibase.properties
Finally I run the command to migrate / initialize the database independently of spring boot :
My question is whether there are any other better options to initialize the database only once ? Should this be incorporated into the
quartz-manager-starter-persistence
project as an alternate option ?