Use Flyway, a DB migration (schema management) library. It is used for the following purposes. -Manage information about DB definitions and their changes in one place. -Automatically reproduce the latest DB status based on that information.
pom.xml
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
By default, Spring Boot runs automatically when the flyway starts.
python
flyway:
baseline-on-migrate: true
baselineVersionAsString: 0.0.0
baseline-description: Initial
Add the sql file to the following folder. src/main/resources/db/migration/
・ Migration file SQL file that describes the changes to be applied to the managed schema Create according to the following rules. V{version}__{description}.sql
Example) V0_0_1__createTable.sql
・ Repeatable migration file Used when you want to migrate objects such as views, procedures, and functions. Create according to the following rules. R__{description}.sql
Example) R__createView.sql
https://flywaydb.org/
Recommended Posts