Skip to content

Commit 418941a

Browse files
Fix PostgreSQL driver conflicts and environment variable loading
- Force PostgreSQL driver in Spring Boot (exclude MySQL driver) - Set Hibernate ddl-auto to 'none' in Docker profile (Flyway manages schema) - Quote 'user' table name in User entity (PostgreSQL reserved keyword) - Add globally_quoted_identifiers to Hibernate config - Update Makefile to explicitly load .env from parent directory - Add comments to docker-compose.yml about .env file location - Add .env.bak and temp-elo-data/ to .gitignore
1 parent bc6df03 commit 418941a

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ model-files copy/
7171
# Maven (keep wrapper, ignore cache)
7272
.mvn/wrapper/maven-wrapper.jar
7373
backend/.mvn/
74+
75+
# Temporary files
76+
.env.bak
77+
temp-elo-data/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
COMPOSE=cd infra && docker compose
1+
COMPOSE=cd infra && docker compose --env-file ../.env
22

33
.PHONY: up down logs ps build
44

backend/src/main/java/com/example/demo/model/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import jakarta.persistence.Table;
88

99
@Entity
10-
@Table(name = "user")
10+
@Table(name = "\"user\"")
1111
public class User {
1212
@Id
1313
@GeneratedValue(strategy = GenerationType.IDENTITY)

backend/src/main/resources/application-docker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ flask.api.url=${FLASK_API_URL:http://flask-ml:5001}
1313
internal.api.token=${INTERNAL_API_TOKEN}
1414

1515
# Disable ddl-auto in production (use Flyway)
16-
spring.jpa.hibernate.ddl-auto=validate
16+
spring.jpa.hibernate.ddl-auto=none
1717
spring.jpa.show-sql=false
1818

1919
# Reduce logging in production

backend/src/main/resources/application.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/f
66
spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres}
77
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:password}
88
spring.datasource.driver-class-name=org.postgresql.Driver
9+
# Force PostgreSQL driver - prevent auto-detection of other drivers
10+
spring.datasource.hikari.driver-class-name=org.postgresql.Driver
911

1012
# HikariCP Configuration (Connection Pool)
1113
spring.datasource.hikari.maximum-pool-size=5
@@ -19,6 +21,8 @@ spring.datasource.hikari.initialization-fail-timeout=60000
1921
spring.jpa.hibernate.ddl-auto=update
2022
spring.jpa.show-sql=true
2123
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
24+
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
25+
spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definitions=false
2226

2327
# PostgreSQL Configuration
2428
spring.datasource.hikari.data-source-properties.preparedStatementCacheQueries=250

infra/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Docker Compose file - version field is obsolete in newer versions
2+
# Note: .env file should be in parent directory (../.env)
3+
# Use: docker compose --env-file ../.env up
4+
# Or run from root: make up
25

36
networks:
47
app-net:

0 commit comments

Comments
 (0)