50

I'm using spring boot with spring.jpa.hibernate.ddl-auto=create, but when application restarted, all tables drops and creates again. Is there some way to avoiding re-creation for already existing tables?

gorill
  • 1,623
  • 3
  • 20
  • 29

2 Answers2

106

The list of option which is used in the spring boot 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
  • none: is all other cases.

So for avoiding the data lose you use update

sudar
  • 1,446
  • 2
  • 14
  • 26
74
spring.jpa.hibernate.ddl-auto=update

hibernate.ddl-auto should usually not be used in production.

samlewis
  • 3,950
  • 27
  • 27