Spring boot ddl auto generator
Asked Answered
P

2

52

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?

Prosecutor answered 14/1, 2014 at 12:5 Comment(0)
B
76
spring.jpa.hibernate.ddl-auto=update

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

Britannia answered 14/1, 2014 at 12:7 Comment(4)
@IllSc lots of discussion here: #221879Britannia
WHY should not be used in production?Calloway
Check the link in my previous comment.Britannia
Can't find this wordsCalloway
O
109

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

Orta answered 31/3, 2016 at 18:48 Comment(0)
B
76
spring.jpa.hibernate.ddl-auto=update

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

Britannia answered 14/1, 2014 at 12:7 Comment(4)
@IllSc lots of discussion here: #221879Britannia
WHY should not be used in production?Calloway
Check the link in my previous comment.Britannia
Can't find this wordsCalloway

© 2022 - 2024 — McMap. All rights reserved.