In this article we saw how to upgrade the DB schema in Spring Boot projects using the spring.jpa properties:
Read more in the official Liquibase site.
- spring.jpa.generate-ddl
- spring.jpa.hibernate.ddl-auto
- Add org.liquibase:liquibase-core to your classpath.
- Create a new changelog file (json):
{
"databaseChangeLog": [
{
"changeSet": {
"id": "1",
"author": "AUTHOR_NAME",
"changes": [
{
"addColumn": {
"columns": [
{
"column": {
"name": "EMAIL",
"type": "VARCHAR(255)",
"defaultValue": email@email.com,
"constraints": {
"nullable": false
}
}
}
],
"schemaName": "MY_SHEMA_NAME",
"tableName": "MY_TABLE_NAME"
}
}
]
}
}
]
}
- Run liquibase update (this will run automatically when you start your Spring Boot project (make sure you set the changelog's path correctly in application.properties (liquibase.change-log=classpath:db/changelog/db.changelog-master.json))
Read more in the official Liquibase site.