Skip to content

Commit

Permalink
[TRAC-13] - refactoring sql statements
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrRym committed Dec 5, 2024
1 parent 116a5a9 commit bbbc77f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
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
15 changes: 8 additions & 7 deletions src/main/resources/db.migration/V1__user-table-creating.sql
Original file line number Diff line number Diff line change
@@ -1,8 +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)
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)
);
25 changes: 13 additions & 12 deletions src/main/resources/db.migration/V2__monitoring-table-creating.sql
Original file line number Diff line number Diff line change
@@ -1,13 +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
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
);

0 comments on commit bbbc77f

Please sign in to comment.