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
154 changes: 83 additions & 71 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,76 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dizio1</groupId>
<artifactId>watchvault</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>watchvault</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dizio1</groupId>
<artifactId>watchvault</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>watchvault</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.16</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class ReviewEntity {
private Long id;
@Column(nullable = false)
private Long showId;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private ShowType showType;
@Column(nullable = false)
private String title;
private String description;
private Integer rating;
Expand Down
13 changes: 11 additions & 2 deletions src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ spring:
jpa:
show-sql: true
hibernate:
ddl-auto: update
ddl-auto: create-drop
properties:
hibernate:
format_sql: true
jackson:
property-naming-strategy: SNAKE_CASE
flyway:
enabled: false
management:
endpoint:
health:
show-details: always
springdoc:
api-docs:
enabled: true
security:
jwt:
secret: ${JWT_SECRET}
tmdb:
base-url: ${TMDB_BASE_URL}
token: ${TMDB_TOKEN}
token: ${TMDB_TOKEN}
32 changes: 32 additions & 0 deletions src/main/resources/application-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
spring:
datasource:
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
driver-class-name: org.postgresql.Driver
jpa:
show-sql: false
hibernate:
ddl-auto: validate
properties:
hibernate:
format_sql: true
jackson:
property-naming-strategy: SNAKE_CASE
flyway:
enabled: true
validate-on-migrate: true
locations: classpath:db/migration
management:
endpoint:
health:
show-details: never
springdoc:
api-docs:
enabled: true
security:
jwt:
secret: ${JWT_SECRET}
tmdb:
base-url: ${TMDB_BASE_URL}
token: ${TMDB_TOKEN}
9 changes: 9 additions & 0 deletions src/main/resources/db/migration/V1__create_movies_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE movies
(
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
title VARCHAR(255) NOT NULL UNIQUE,
directed_by VARCHAR(255),
overview TEXT,
runtime INT,
release_date DATE
);
12 changes: 12 additions & 0 deletions src/main/resources/db/migration/V2__create_series_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE series
(
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
title VARCHAR(255),
description TEXT NOT NULL,
created_by VARCHAR(255),
episodes INT,
seasons INT,
first_air_date DATE,
last_air_date DATE,
status VARCHAR(255)
);
5 changes: 5 additions & 0 deletions src/main/resources/db/migration/V3__create_genres_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE genres
(
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name VARCHAR(50) NOT NULL UNIQUE
);
10 changes: 10 additions & 0 deletions src/main/resources/db/migration/V4__create_reviews_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE reviews
(
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
show_id BIGINT NOT NULL,
show_type VARCHAR(20) NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
rating INT CHECK (rating BETWEEN 1 AND 10),
reviewed_at DATE
);
17 changes: 17 additions & 0 deletions src/main/resources/db/migration/V5__create_movies_genres_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE movies_genres
(
movie_id BIGINT NOT NULL,
genre_id BIGINT NOT NULL,

PRIMARY KEY (movie_id, genre_id),

CONSTRAINT fk_movies_genres_movie
FOREIGN KEY (movie_id)
REFERENCES movies (id)
ON DELETE CASCADE,

CONSTRAINT fk_movies_genres_genre
FOREIGN KEY (genre_id)
REFERENCES genres (id)
ON DELETE CASCADE
);
17 changes: 17 additions & 0 deletions src/main/resources/db/migration/V6__create_series_genres_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE series_genres
(
series_id BIGINT NOT NULL,
genre_id BIGINT NOT NULL,

PRIMARY KEY (series_id, genre_id),

CONSTRAINT fk_series_genres_series
FOREIGN KEY (series_id)
REFERENCES series (id)
ON DELETE CASCADE,

CONSTRAINT fk_series_genres_genres
FOREIGN KEY (genre_id)
REFERENCES genres (id)
ON DELETE CASCADE
)
6 changes: 6 additions & 0 deletions src/main/resources/db/migration/V7__create_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Many to many
CREATE INDEX idx_movies_genres_movie
ON movies_genres (movie_id);

CREATE INDEX idx_series_genres_series
ON series_genres (series_id);