- 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:
@@ -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