0

I have a spring-boot application which needs to be moved to production. I need to define strategy to instantiate the DB for this which includes creating tables in the Database and adding some default values

I saw spring.jpa.hibernate.ddl feature but this will create/drop each time my application is restarted. Also, i read a bit about flyway but that seems to be a complex DB migration tool and all i have to do is create some tables if not present. Also, i need to be able to control the priority for the different sql scripts that will run.

Is there any simple approach (preferably open source) to run multiple sql scrips from a spring boot application with a defined priority.

1 Answers1

0

You could use update rather than create

spring.jpa.hibernate.ddl-auto=update

Some other options other than create and update are:

  • validate: validate the schema, makes no changes to the database.
  • update: update the schema.
  • create: creates the schema, destroying previous data.
  • create-drop: drop the schema at the end of the session

Note: But still this is not safe/preferred in production due to various reasons. Hibernate: hbm2ddl.auto=update in production?

Mebin Joe
  • 2,172
  • 4
  • 16
  • 22
  • Ok, so we will not be using this approach. How is flyway for this ? Is it simple enough to be implemented in a small application. I don't want t get into a situation where the DB part is more complex than the complete application :) – jatin bajaj Apr 10 '19 at 11:37