Cho em hỏi spring boot dùng cái gì để có thể update lại được các trường trong DB mỗi khi em thêm hoặc xóa 1 trường trong entity ạ. Em cảm ơn .
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Em có thể dùng
hibernate.hbm2ddl.auto="update"
hoặchibernate.hbm2ddl.auto="create-drop"
(thêm vào file application.properties)2. Tuy nhiên là cái này chỉ dùng trong môi trường test thôi, vì nó sẽ xoá dữ liệu đi tạo lại nên em không nên dùng ở môi trường chạy production em ạ.
vậy có cách nào để chạy production không ạ
Em có thể sử dụng thư viện flyway này. Em sẽ phải tạo các script tương ứng với các version em muốn thay đổi, các script này có thể là tạo bảng, alter bảng, … nhưng nó sẽ không tự động thay đổi theo Entity, mà em vẫn phải tự viết sql script em ạ
Em cảm ơn ạ