- Added Flyway sql scripts
- Added SQL constraints added to respective tables see list below: -- video_playlist: video_id playlist_id -- Foreign keys reference originals, on delete cascade on both - Added Java JPA Entity column name mapping to snake_case instead of using base Java camelCase
This commit is contained in:
23
pom.xml
23
pom.xml
@@ -44,14 +44,22 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.40</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-database-postgresql</artifactId>
|
||||
<version>12.0.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-flyway</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
@@ -81,6 +89,17 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-maven-plugin</artifactId>
|
||||
<version>12.0.1</version>
|
||||
<configuration>
|
||||
<url>jdbc:postgresql://127.0.0.1:5432/videos</url>
|
||||
<user>postgres</user>
|
||||
<password>5995</password>
|
||||
<cleanDisabled>false</cleanDisabled>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
@Entity
|
||||
public class Creator {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -13,10 +13,10 @@ import java.util.List;
|
||||
|
||||
public class Playlist {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
@Column(name = "playlist_name", nullable = false)
|
||||
private String playlistName;
|
||||
|
||||
@Column
|
||||
|
||||
@@ -14,17 +14,21 @@ import java.util.List;
|
||||
@Table(name = "videos")
|
||||
public class Video {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String url;
|
||||
private String name;
|
||||
|
||||
@Column(name = "upload_date")
|
||||
private String uploadDate;
|
||||
|
||||
private String duration;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private StatusEnum status;
|
||||
|
||||
@Column(name="full_path")
|
||||
private String fullPath;
|
||||
|
||||
@ManyToMany
|
||||
|
||||
@@ -38,7 +38,6 @@ public class YTDLPService {
|
||||
|
||||
public void processPlaylist() throws IOException, InterruptedException {
|
||||
List<Playlist> playlists = playlistRepository.findByStatus(StatusEnum.NEW);
|
||||
System.out.println("Am I slow?");
|
||||
for(Playlist playlist : playlists) {
|
||||
String urls = processService.execute("yt-dlp", "--force-ipv4", "--flat-playlist", "--print", "webpage_url", playlist.getUrl());
|
||||
for(String url : urls.split("\\n")){
|
||||
|
||||
@@ -2,4 +2,8 @@ spring.application.name=video_downloader
|
||||
spring.datasource.url = jdbc:postgresql://127.0.0.1:5432/videos
|
||||
spring.datasource.username = postgres
|
||||
spring.datasource.password = 5995
|
||||
spring.jpa.hibernate.ddl-auto = create-drop
|
||||
spring.jpa.hibernate.ddl-auto = none
|
||||
logging.level.org.flywaydb=DEBUG
|
||||
logging.level.org.springframework.boot.autoconfigure.flyway=DEBUG
|
||||
spring.flyway.enabled=true
|
||||
spring.flyway.baseline-on-migrate=true
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE playlists (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
playlist_name VARCHAR(100) NOT NULL,
|
||||
url VARCHAR(200) NOT NULL,
|
||||
status VARCHAR(10) NOT NULL
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE videos (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(200),
|
||||
url VARCHAR(200) NOT NULL,
|
||||
upload_date VARCHAR(100),
|
||||
duration VARCHAR(10),
|
||||
status VARCHAR(10) NOT NULL,
|
||||
full_path VARCHAR(100)
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE creator (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name VARCHAR(200) NOT NULL,
|
||||
url VARCHAR(200) NOT NULL
|
||||
);
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE video_playlist (
|
||||
video_id BIGINT NOT NULL,
|
||||
playlist_id BIGINT NOT NULL,
|
||||
PRIMARY KEY (video_id, playlist_id),
|
||||
FOREIGN KEY (video_id) REFERENCES videos(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (playlist_id) REFERENCES playlists(id) ON DELETE CASCADE
|
||||
);
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE videos
|
||||
ADD COLUMN creator_id BIGINT,
|
||||
ADD CONSTRAINT fk_videos_creator FOREIGN KEY (creator_id) REFERENCES creator(id)
|
||||
|
||||
Reference in New Issue
Block a user