Skip to content

Commit 475af04

Browse files
committed
added liquibase
1 parent 359f01a commit 475af04

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787
<groupId>org.springframework.kafka</groupId>
8888
<artifactId>spring-kafka</artifactId>
8989
</dependency>
90+
<dependency>
91+
<groupId>org.liquibase</groupId>
92+
<artifactId>liquibase-core</artifactId>
93+
<version>4.31.1</version>
94+
</dependency>
9095
</dependencies>
9196

9297
<build>

src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ spring.datasource.url=jdbc:postgresql://localhost:5433/app_db
77
spring.datasource.username=app_user
88
spring.datasource.password=secretpass
99
spring.datasource.driver-class-name=org.postgresql.Driver
10+
spring.liquibase.enabled=true
11+
spring.liquibase.change-log=changelog/db.changelog-master.xml
1012

1113
spring.jpa.hibernate.ddl-auto=update
1214
spring.jpa.show-sql=true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<databaseChangeLog
2+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
5+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
6+
7+
<include file="migrations/2025-04-15-initial-changelog.xml" relativeToChangelogFile="true"/>
8+
</databaseChangeLog>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
7+
8+
<changeSet id="1" author="Zverev-DE">
9+
<preConditions onFail="MARK_RAN">
10+
<not>
11+
<tableExists tableName="users"/>
12+
</not>
13+
</preConditions>
14+
<createTable tableName="users">
15+
<column name="id" type="BIGINT" autoIncrement="true">
16+
<constraints primaryKey="true" nullable="false"/>
17+
</column>
18+
<column name="chat_id" type="BIGINT">
19+
<constraints nullable="true"/>
20+
</column>
21+
<column name="name" type="VARCHAR(255)">
22+
<constraints nullable="true"/>
23+
</column>
24+
</createTable>
25+
</changeSet>
26+
27+
<changeSet id="2" author="Zverev-DE">
28+
<preConditions onFail="MARK_RAN">
29+
<tableExists tableName="users"/>
30+
<not>
31+
<tableExists tableName="note"/>
32+
</not>
33+
</preConditions>
34+
<createTable tableName="note">
35+
<column name="id" type="BIGINT" autoIncrement="true">
36+
<constraints primaryKey="true" nullable="false"/>
37+
</column>
38+
<column name="users_id" type="BIGINT">
39+
<constraints nullable="false" foreignKeyName="fk_note_users" references="users(id)"/>
40+
</column>
41+
<column name="content" type="VARCHAR(255)">
42+
<constraints nullable="true"/>
43+
</column>
44+
</createTable>
45+
</changeSet>
46+
47+
<changeSet id="3" author="Zverev-DE">
48+
<preConditions onFail="MARK_RAN">
49+
<not>
50+
<tableExists tableName="chat_gpt_messages"/>
51+
</not>
52+
</preConditions>
53+
<createTable tableName="chat_gpt_messages">
54+
<column name="id" type="BIGINT" autoIncrement="true">
55+
<constraints primaryKey="true" nullable="false"/>
56+
</column>
57+
<column name="question" type="VARCHAR(5000)">
58+
<constraints nullable="true"/>
59+
</column>
60+
<column name="answer" type="VARCHAR(5000)">
61+
<constraints nullable="true"/>
62+
</column>
63+
<column name="user_id" type="BIGINT">
64+
<constraints nullable="true"/>
65+
</column>
66+
</createTable>
67+
</changeSet>
68+
69+
</databaseChangeLog>

0 commit comments

Comments
 (0)