From 2b74db43ddcbf45d161a6cd66cbdc1cb56fc0f2b Mon Sep 17 00:00:00 2001 From: litoral05 Date: Tue, 5 May 2026 10:04:51 +0100 Subject: [PATCH] Add flyway initial schema and database setup --- .gitignore | 3 +++ docker-compose.yml | 12 ++++++++++ src/main/resources/application.yaml | 22 +++++++++++++++++++ .../db/migration/V1__initial_schema.sql | 10 +++++++++ 4 files changed, 47 insertions(+) create mode 100644 docker-compose.yml create mode 100644 src/main/resources/db/migration/V1__initial_schema.sql diff --git a/.gitignore b/.gitignore index 667aaef..05a1c0c 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ build/ ### VS Code ### .vscode/ + +### Postgres ### +postgres-data/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b043e84 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + postgres: + image: postgres:16 + container_name: lr-openvpn-postgres + environment: + POSTGRES_DB: lr_openvpn + POSTGRES_USER: lr_openvpn + POSTGRES_PASSWORD: lr_openvpn_dev + ports: + - "5432:5432" + volumes: + - ./postgres-data:/var/lib/postgresql/data \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 1e495fc..7652351 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,3 +1,25 @@ spring: application: name: lr-openvpn-backend + + datasource: + url: jdbc:postgresql://localhost:5432/lr_openvpn + username: lr_openvpn + password: lr_openvpn_dev + + jpa: + hibernate: + ddl-auto: validate + open-in-view: false + + flyway: + enabled: true + +server: + port: 8080 + +management: + endpoints: + web: + exposure: + include: health,info \ No newline at end of file diff --git a/src/main/resources/db/migration/V1__initial_schema.sql b/src/main/resources/db/migration/V1__initial_schema.sql new file mode 100644 index 0000000..b2b2f14 --- /dev/null +++ b/src/main/resources/db/migration/V1__initial_schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE vps_servers ( + id UUID PRIMARY KEY, + name VARCHAR(120) NOT NULL, + host VARCHAR(255) NOT NULL, + ssh_port INTEGER NOT NULL DEFAULT 22, + ssh_user VARCHAR(120) NOT NULL, + status VARCHAR(40) NOT NULL DEFAULT 'UNKNOWN', + created_at TIMESTAMP NOT NULL DEFAULT now(), + updated_at TIMESTAMP NOT NULL DEFAULT now() +); \ No newline at end of file