Site icon Tweet A Beer

Executing .sql files from classpath, while the service is running

I am working on a project and I need the following functionality :

I have a Springboot Tomcat server running, what I want is the ability to automatically scan a specific location for .SQL files and execute the said DML and DDL commands in a specific database. However I want this to be dynamic as in, the moment a new file is added to the location, it is picked up and executed.

I tried Flyway, but it only picks the files from the path at startup. Is there any efficient way to do this? One way I have thought of is to schedule a CRON and periodically scan the path for files and execute all the SQL files and have procedures on the DB tables to prevent unnecessary updates(executing an update which was already done before).

Exit mobile version