Skip to content

Commit

Permalink
add liquibase
Browse files Browse the repository at this point in the history
  • Loading branch information
BBesrour committed Sep 29, 2024
1 parent ec97c69 commit c727cd7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation "org.apache.commons:commons-lang3"
implementation "com.zaxxer:HikariCP"
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.liquibase:liquibase-core'
testImplementation "org.springframework.boot:spring-boot-starter-test"
runtimeOnly 'com.mysql:mysql-connector-j'
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ spring:
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
liquibase:
enabled: true
change-log: classpath:db/changelog/db.changelog-master.xml
jpa:
hibernate:
ddl-auto: update
ddl-auto: none
naming:
physical-strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<!-- Reference changesets here -->
<include file="classpath:db/changelog/initial-schema.xml"/>
<!-- <include file="classpath:db/changelog/20240929130000.xml"/>-->
</databaseChangeLog>
23 changes: 23 additions & 0 deletions src/main/resources/db/changelog/initial-schema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<!-- Example: Create Table -->
<changeSet id="2024092812000000" author="bbesrour">
<createTable tableName="telemetry">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="admin_name" type="VARCHAR(255)"/>
<column name="contact" type="VARCHAR(255)"/>
<column name="operator_name" type="VARCHAR(255)"/>
<column name="profiles" type="VARCHAR(255)"/>
<column name="server_url" type="VARCHAR(255)"/>
<column name="timestamp" type="datetime(6)"/>
<column name="version" type="VARCHAR(255)"/>
</createTable>
</changeSet>

</databaseChangeLog>

0 comments on commit c727cd7

Please sign in to comment.