diff --git a/rest-api/build.gradle b/rest-api/build.gradle
index 05a8ce9..603bcc8 100644
--- a/rest-api/build.gradle
+++ b/rest-api/build.gradle
@@ -1,6 +1,7 @@
plugins {
id "io.freefair.lombok"
id 'org.springframework.boot'
+ id "org.liquibase.gradle" version "2.0.4"
}
dependencies {
@@ -8,6 +9,8 @@ dependencies {
implementation project(':fns-sdk')
implementation project(':rest-api-dto')
+ compile group: 'org.liquibase', name: 'liquibase-core', version: '4.0.0'
+
implementation 'com.google.code.findbugs:jsr305'
implementation 'commons-codec:commons-codec'
implementation 'org.apache.commons:commons-lang3'
@@ -16,6 +19,7 @@ dependencies {
implementation 'org.projectlombok:lombok'
implementation 'org.springdoc:springdoc-openapi-ui'
+ implementation "org.liquibase:liquibase-gradle-plugin:2.0.4"
testImplementation project(':test-util')
testImplementation "com.h2database:h2"
diff --git a/rest-api/src/main/resources/changelog/liquibase-changelog.xml b/rest-api/src/main/resources/changelog/liquibase-changelog.xml
new file mode 100644
index 0000000..d10c75f
--- /dev/null
+++ b/rest-api/src/main/resources/changelog/liquibase-changelog.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest-api/src/main/resources/config/application.properties b/rest-api/src/main/resources/config/application.properties
index d883cd6..b6c8290 100644
--- a/rest-api/src/main/resources/config/application.properties
+++ b/rest-api/src/main/resources/config/application.properties
@@ -1,2 +1,6 @@
springdoc.api-docs.path=/documentation
springdoc.swagger-ui.path=/documentation/view
+
+# Liquibase
+spring.liquibase.enabled=false
+spring.liquibase.change-log=classpath:/changelog/liquibase-changelog.xml
diff --git a/rest-api/src/main/resources/db/db.changelog-1.0.xml b/rest-api/src/main/resources/db/db.changelog-1.0.xml
new file mode 100644
index 0000000..cc43ccb
--- /dev/null
+++ b/rest-api/src/main/resources/db/db.changelog-1.0.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/rest-api/src/main/resources/db/sql/202009071830_Create_Table_item.sql b/rest-api/src/main/resources/db/sql/202009071830_Create_Table_item.sql
new file mode 100644
index 0000000..c7ba30b
--- /dev/null
+++ b/rest-api/src/main/resources/db/sql/202009071830_Create_Table_item.sql
@@ -0,0 +1,16 @@
+create table IF NOT EXISTS item
+(
+ id bigserial not null
+ constraint item_pkey
+ primary key,
+ amount double precision not null,
+ price double precision not null,
+ text varchar(255) not null,
+ receipt_id bigint
+ constraint fk8s305nsnv4wi5iuh7kkr52gqt
+ references receipt
+);
+
+alter table item
+ owner to receipt_dev;
+
diff --git a/rest-api/src/main/resources/db/sql/202009071831_Create_Table_receipt.sql b/rest-api/src/main/resources/db/sql/202009071831_Create_Table_receipt.sql
new file mode 100644
index 0000000..fe427b1
--- /dev/null
+++ b/rest-api/src/main/resources/db/sql/202009071831_Create_Table_receipt.sql
@@ -0,0 +1,27 @@
+create table IF NOT EXISTS receipt
+(
+ id bigserial not null
+ constraint receipt_pkey
+ primary key,
+ date timestamp not null,
+ fd varchar(255) not null,
+ fn varchar(255) not null,
+ fp varchar(255) not null,
+ provider varchar(255),
+ status varchar(255) not null,
+ sum double precision not null,
+ place_id bigint
+ constraint fk2x2wkgo5re36vwpxctma1o4s6
+ references place,
+ merchant_inn varchar(255),
+ merchant_name varchar(255),
+ merchant_place_address varchar(255),
+ user_profile_id varchar(255)
+ constraint fk7n4ubagih0n1tdwvx4h7qdn5d
+ references user_profile,
+ load_attempts bigint default 0
+);
+
+alter table receipt
+ owner to receipt_dev;
+
diff --git a/rest-api/src/main/resources/db/sql/202009071832_Create_Table_place.sql b/rest-api/src/main/resources/db/sql/202009071832_Create_Table_place.sql
new file mode 100644
index 0000000..3d33b0e
--- /dev/null
+++ b/rest-api/src/main/resources/db/sql/202009071832_Create_Table_place.sql
@@ -0,0 +1,11 @@
+create table IF NOT EXISTS place
+(
+ id bigserial not null
+ constraint place_pkey
+ primary key,
+ text varchar(255) not null
+);
+
+alter table place
+ owner to receipt_dev;
+
diff --git a/rest-api/src/main/resources/db/sql/202009071833_Create_Table_user_profile.sql b/rest-api/src/main/resources/db/sql/202009071833_Create_Table_user_profile.sql
new file mode 100644
index 0000000..9e41fec
--- /dev/null
+++ b/rest-api/src/main/resources/db/sql/202009071833_Create_Table_user_profile.sql
@@ -0,0 +1,21 @@
+create table IF NOT EXISTS user_profile
+(
+ id varchar(255) not null
+ constraint user_profile_pkey
+ primary key,
+ created_at timestamp not null,
+ updated_at timestamp,
+ access_token varchar(255),
+ fns_request_count integer,
+ password varchar(255) not null,
+ phone varchar(255) not null
+ constraint uk_1un6sdkbtaspkwmsiferm1dhm
+ unique,
+ load_count integer default 0 not null,
+ email varchar(255),
+ name varchar(255)
+);
+
+alter table user_profile
+ owner to receipt_dev;
+
diff --git a/rest-api/src/main/resources/db/sql/202009071834_Create_Table_merchant.sql b/rest-api/src/main/resources/db/sql/202009071834_Create_Table_merchant.sql
new file mode 100644
index 0000000..731ee88
--- /dev/null
+++ b/rest-api/src/main/resources/db/sql/202009071834_Create_Table_merchant.sql
@@ -0,0 +1,14 @@
+create table IF NOT EXISTS merchant
+(
+ id bigserial not null
+ constraint merchant_pkey
+ primary key,
+ address varchar(255) not null,
+ inn varchar(255) not null,
+ last_update_time timestamp not null,
+ name varchar(255) not null
+);
+
+alter table merchant
+ owner to receipt_dev;
+
diff --git a/rest-api/src/test/resources/application.properties b/rest-api/src/test/resources/application.properties
index 1698366..bc6d818 100644
--- a/rest-api/src/test/resources/application.properties
+++ b/rest-api/src/test/resources/application.properties
@@ -13,4 +13,8 @@ spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
# Hibernate ddl auto (create, create-drop, validate, update)
-spring.jpa.hibernate.ddl-auto=create-drop
\ No newline at end of file
+spring.jpa.hibernate.ddl-auto=create-drop
+
+# Liquibase
+spring.liquibase.enabled=false
+spring.liquibase.change-log=classpath:/changelog/liquibase-changelog.xml