Learn Why and How to Use Relational Database Migrations
Too Long; Didn't ReadIntroduction When developing backend services, it’s effortless to create problems if database integration is implemented incorrectly.
Nowadays, developers mostly use two approaches: Automatic generation, e.g., JPA or Hibernate - database initializes and keeps up to date by comparing classes and the current DB state; if changes are needed, they apply.
That means that in Hibernate entity, we add the new column: @Column(name = "receive_notifications", nullable = false) private Boolean receiveNotifications; After starting the app, we see the error in logs and no new column.
Each developer requires a separate environment.
But it’s better next time to consider migrations because it will relieve Java entities, remove excess responsibility, and benefit you with a lot of control over DDL.
You can find the fully working example on GitHub.