Добавил spring jpa и liquibase

feature/task-15-add_db
L_DelOff 2023-08-09 22:18:02 +03:00
parent c174f36848
commit 047502916a
6 changed files with 60 additions and 2 deletions

View File

@ -47,6 +47,14 @@
<artifactId>jsch</artifactId> <artifactId>jsch</artifactId>
<version>0.1.55</version> <version>0.1.55</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -20,8 +20,6 @@ public class TelegramBotController extends TelegramLongPollingBot {
final TelegramBot telegramBot; final TelegramBot telegramBot;
final SshRepository sshRepository; final SshRepository sshRepository;
final TelegramBotKeyboard telegramBotKeyboard;
final UnameChatButtonAggregate unameChatButtonAggregate;
final TelegramBotService telegramBotService; final TelegramBotService telegramBotService;
@Override @Override

View File

@ -1,3 +1,21 @@
spring:
application:
name: ServerMonitorBot
datasource:
url: jdbc:postgresql://localhost:5432/servermonitorbot
username: servermonitorbot
password: servermonitorbot
jpa:
hibernate:
ddl-auto: none
liquibase:
enabled: true
change-log: classpath:db/scripts/changelog-master.xml
url: jdbc:postgresql://localhost:5432/servermonitorbot
user: servermonitorbot
password: servermonitorbot
liquibase-schema: "liquibase"
default-schema: "servermonitorbot"
bot: bot:
name: "ServerMonitorBot" name: "ServerMonitorBot"
token: "token" token: "token"

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="release_0_0_1/changelog.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="scripts/01_create_table_users.sql" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@ -0,0 +1,15 @@
--liquibase formatted sql
--changeset L_DelOff:create_table_users rollbackSplitStatements:true
--comment: Создание таблицы пользователей
CREATE TABLE USERS
(
ID VARCHAR(36) PRIMARY KEY,
NAME VARCHAR(128)
);
COMMENT ON TABLE USERS IS 'Пользователи';
COMMENT ON COLUMN USERS.ID IS 'Идентификатор пользователя';
COMMENT ON COLUMN USERS.NAME IS 'Логин пользователя';
--rollback DROP TABLE RELEASES;