Skip to content

Commit

Permalink
Feature/#10 create init data migration set (#15)
Browse files Browse the repository at this point in the history
create init data migration set
  • Loading branch information
glacial-trail authored Apr 13, 2023
1 parent f5bb344 commit 7930e7b
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 14 deletions.
40 changes: 40 additions & 0 deletions docs/liquibase-changelog-policies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Liquibase changelog policy

For now this document describes how to name changelog files and changeset IDs.

___

### Changelog files naming rule
The pattern for changelog file name is ```yyMMdd.taskID-branchname```.

Where:
* ```yyMMdd``` date when you start (or end) to work on task.
It is needed to preserve chronological order of files during sorting.
* ```taskID``` Zenhub ID of the task
* ```branchname``` the same text as the name of the task branch,
just to have short description in history tables of liquibase(for example).

#### Example
```
220309.10-create_init_data_migration_set
```
### Changeset IDs naming rule
The pattern for changeset ID name is
```taskID.<major-sequential-number|any-text-descriptor>.[minor-sequential-number]```

Where:
* ```taskID``` Zenhub ID of the task
* ```major-sequential-number``` unique ID in scope of current task (major ID)
* ```text-descriptor``` short text descriptor unique in scope of current task (major ID)
* ```minor-sequential-number``` unique ID in scope of major ID (optional)

#### Example:
```
10.route.1
11.2.3
17.5
```

---
P.S. You may want to read
[best practices article](https://www.liquibase.org/get-started/best-practices)
72 changes: 59 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<telegrambots.version>6.5.0</telegrambots.version>
<tinylog-api.version>2.6.0</tinylog-api.version>
<tinylog-impl.version>2.6.0</tinylog-impl.version>
<postgresql.version>42.5.4</postgresql.version>
<liquibase.version>4.19.1</liquibase.version>

<!--Plugin properties-->
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
Expand All @@ -62,18 +64,41 @@
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<!--Project dependencies-->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand All @@ -97,6 +122,12 @@
<artifactId>tinylog-impl</artifactId>
<version>${tinylog-impl.version}</version>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -123,6 +154,7 @@
</pluginManagement>

<plugins>

<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
Expand Down Expand Up @@ -160,6 +192,19 @@
</executions>
</plugin>

<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<searchPath>${project.resourcesDirectory}</searchPath>
<changeLogFile>liquibase-changelog-root.yaml</changeLogFile>
<url>${env.DB_URL}</url>
<username>${env.DB_LOGIN}</username>
<password>${env.DB_PASSWORD}</password>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down Expand Up @@ -188,19 +233,6 @@
</executions>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
Expand All @@ -214,6 +246,20 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>

</plugins>
</build>

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spring.liquibase.enabled=true
spring.liquibase.contexts=dev
spring.liquibase.change-log=classpath:liquibase-changelog-root.yaml
8 changes: 7 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
bot.token=${BOT_TOKEN}
bot.name=${BOT_NAME}
bot.name=${BOT_NAME}

spring.datasource.url=${DB_URL}
spring.datasource.username=${DB_LOGIN}
spring.datasource.password=${DB_PASSWORD}

spring.liquibase.enabled=false
4 changes: 4 additions & 0 deletions src/main/resources/liquibase-changelog-root.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
databaseChangeLog:
- includeAll:
path: liquibase-changelog
relativeToChangelogFile: true
Loading

0 comments on commit 7930e7b

Please sign in to comment.