diff --git a/pom.xml b/pom.xml
index 63f8dd2..e1842d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,7 @@
21
7.10.0
7.10.0
+ 9.22.3
@@ -50,6 +51,11 @@
spring-boot-starter-test
test
+
+ org.flywaydb
+ flyway-core
+ ${flyway.version}
+
diff --git a/src/main/java/com/vladyslavpalamarchuk/trackmycoin/adaptors/telegram/TelegramBotConsumer.java b/src/main/java/com/vladyslavpalamarchuk/trackmycoin/adaptors/telegram/TelegramBotConsumer.java
index 3ee5a27..1a1b60e 100644
--- a/src/main/java/com/vladyslavpalamarchuk/trackmycoin/adaptors/telegram/TelegramBotConsumer.java
+++ b/src/main/java/com/vladyslavpalamarchuk/trackmycoin/adaptors/telegram/TelegramBotConsumer.java
@@ -19,7 +19,7 @@ public class TelegramBotConsumer implements LongPollingSingleThreadUpdateConsume
public void consume(Update update) {
if (update.hasMessage() && update.getMessage().hasText()) {
logUpdateMessage(update.getMessage());
- commandProcessorRegistry.get(update.getMessage().getText()).process(update);
+ commandProcessorRegistry.get(update.getMessage().getText()).process(update);
}
}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 38d0935..d3b2e20 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -8,6 +8,10 @@ spring:
username: ${POSTGRESQL_USERNAME}
password: ${POSTGRESQL_PASSWORD}
driver-class-name: org.postgresql.Driver
+ flyway:
+ enabled: true
+ locations: classpath:db.migration
+ baseline-on-migrate: true
description:
start: "Welcome to TrackMyCoin 📈💰!
\n\nThis bot helps you track cryptocurrency prices
diff --git a/src/main/resources/db.migration/V1__user-table-creating.sql b/src/main/resources/db.migration/V1__user-table-creating.sql
new file mode 100644
index 0000000..cc9cd53
--- /dev/null
+++ b/src/main/resources/db.migration/V1__user-table-creating.sql
@@ -0,0 +1,9 @@
+CREATE TABLE users
+(
+ id BIGSERIAL PRIMARY KEY,
+ chat_id BIGINT NOT NULL,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ created_by VARCHAR(255),
+ updated_by VARCHAR(255)
+);
diff --git a/src/main/resources/db.migration/V2__monitoring-table-creating.sql b/src/main/resources/db.migration/V2__monitoring-table-creating.sql
new file mode 100644
index 0000000..d5aecf6
--- /dev/null
+++ b/src/main/resources/db.migration/V2__monitoring-table-creating.sql
@@ -0,0 +1,14 @@
+CREATE TABLE monitorings
+(
+ id BIGSERIAL PRIMARY KEY,
+ ticker VARCHAR(100) NOT NULL,
+ target_price DECIMAL(18, 2) NOT NULL,
+ user_id BIGINT NOT NULL,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ created_by VARCHAR(255),
+ updated_by VARCHAR(255),
+ CONSTRAINT fk_monitorings_users FOREIGN KEY (user_id) REFERENCES users (id)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE
+);
\ No newline at end of file