Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spring.application.name=boardGameTraining
server.port=8080

# JPA properties
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
spring.jpa.show-sql=true

Expand All @@ -39,6 +39,12 @@ spring.datasource.password=postgres
external.service.host=localhost
external.service.port=8081
external.service.scheme=http

# Flyway
spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migration
spring.flyway.baseline-on-migrate=true

```
### 3. Build and Run the Project
#### Using Maven
Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ spring.application.name=boardGameTraining
server.port=8080

# JPA properties
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
spring.jpa.show-sql=true

Expand All @@ -21,3 +21,8 @@ spring.datasource.password=postgres
external.service.host=localhost
external.service.port=8081
external.service.scheme=http

# Flyway
spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migration
spring.flyway.baseline-on-migrate=true
70 changes: 70 additions & 0 deletions src/main/resources/db/migration/V1__init_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
CREATE TABLE public.games (
id bigint NOT NULL,
age integer,
artists character varying(255)[],
authors character varying(255)[],
bgg_id bigint,
max_playtime integer,
max_players integer,
min_playtime integer,
min_players integer,
title character varying(255),
type character varying(255),
url_image character varying(255),
url_thumbnail character varying(255),
year integer
);

ALTER TABLE public.games ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.games_id_seq
START WITH 1 INCREMENT BY 1
);

ALTER TABLE public.games ADD CONSTRAINT games_pkey PRIMARY KEY (id);
ALTER TABLE public.games ADD CONSTRAINT UKntmh3x14muumi2b0mskyio2j4 UNIQUE (bgg_id);

CREATE TABLE public.players (
id bigint NOT NULL,
name character varying(255),
nickname character varying(255)
);

ALTER TABLE public.players ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.players_id_seq
START WITH 1 INCREMENT BY 1
);

ALTER TABLE public.players ADD CONSTRAINT players_pkey PRIMARY KEY (id);
ALTER TABLE public.players ADD CONSTRAINT UKqgdybxl68dc8afxn41k2pasxg UNIQUE (nickname);

CREATE TABLE public.plays (
id bigint NOT NULL,
location character varying(255),
id_game bigint,
winner_id bigint
);

ALTER TABLE public.plays ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.plays_id_seq
START WITH 1 INCREMENT BY 1
);

ALTER TABLE public.plays ADD CONSTRAINT plays_pkey PRIMARY KEY (id);

CREATE TABLE public.play_players (
play_id bigint NOT NULL,
player_id bigint NOT NULL
);

-- Foreign keys
ALTER TABLE public.play_players
ADD CONSTRAINT FK6klixhjpf6x2ix8v34ugh12eq FOREIGN KEY (player_id) REFERENCES public.players(id);

ALTER TABLE public.play_players
ADD CONSTRAINT FKp2woirp1fvcu13vlxls3dw0kh FOREIGN KEY (play_id) REFERENCES public.plays(id);

ALTER TABLE public.plays
ADD CONSTRAINT FKa72o52yygyuveym3t1sm4mee3 FOREIGN KEY (id_game) REFERENCES public.games(id);

ALTER TABLE public.plays
ADD CONSTRAINT FKpyln8jt1mg97yoyfnk7psutco FOREIGN KEY (winner_id) REFERENCES public.players(id);