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