Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRAC - 13] - Implement Flyway and add DDL(V1, V2) #9

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<java.version>21</java.version>
<telegrambots-longpolling.version>7.10.0</telegrambots-longpolling.version>
<telegrambots-client.version>7.10.0</telegrambots-client.version>
<flyway.version>9.22.3</flyway.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -50,6 +51,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/db.migration/V1__user-table-creating.sql
Original file line number Diff line number Diff line change
@@ -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)
);
14 changes: 14 additions & 0 deletions src/main/resources/db.migration/V2__monitoring-table-creating.sql
Original file line number Diff line number Diff line change
@@ -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
);
Loading