2020-10-27 21:38:19 +01:00
|
|
|
DROP TABLE IF EXISTS properties, films, languages, subtitle_lines, subtitles;
|
2020-10-27 14:49:18 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Store some information on the application.
|
|
|
|
*/
|
2020-10-27 21:38:19 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS properties
|
2020-10-27 14:49:18 +01:00
|
|
|
(
|
|
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
|
|
app_key text NOT NULL,
|
|
|
|
app_value text NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (app_key)
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Film
|
|
|
|
*/
|
2020-10-27 21:38:19 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS films
|
2020-10-27 14:49:18 +01:00
|
|
|
(
|
2020-10-28 16:14:58 +01:00
|
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
|
|
imdb_id varchar(10) NOT NULL,
|
|
|
|
title text NOT NULL,
|
|
|
|
year int,
|
|
|
|
film_type text NOT NULL,
|
|
|
|
season int,
|
|
|
|
episode int,
|
|
|
|
poster_link text,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (imdb_id)
|
2020-10-27 14:49:18 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Available languages
|
|
|
|
*/
|
2020-10-27 21:38:19 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS languages
|
2020-10-27 14:49:18 +01:00
|
|
|
(
|
|
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
|
|
alpha3_b char(3) NOT NULL,
|
|
|
|
alpha3_t char(3),
|
|
|
|
alpha2 char(2),
|
|
|
|
english text NOT NULL,
|
|
|
|
french text NOT NULL,
|
2020-10-27 21:38:19 +01:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (alpha3_b)
|
2020-10-27 14:49:18 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Subtitles
|
|
|
|
*/
|
2020-10-27 21:38:19 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS subtitles
|
2020-10-27 14:49:18 +01:00
|
|
|
(
|
2020-10-28 16:14:58 +01:00
|
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
|
|
film_id int NOT NULL,
|
|
|
|
language_id int NOT NULL,
|
2020-10-29 11:51:19 +01:00
|
|
|
importer_id varchar(37),
|
2020-10-28 16:14:58 +01:00
|
|
|
importer_guild_id text,
|
|
|
|
imported_date timestamptz NOT NULL DEFAULT now(),
|
2020-10-27 14:49:18 +01:00
|
|
|
UNIQUE (film_id, language_id),
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (film_id)
|
2020-10-27 21:38:19 +01:00
|
|
|
REFERENCES films (id),
|
2020-10-27 14:49:18 +01:00
|
|
|
FOREIGN KEY (language_id)
|
2020-10-27 21:38:19 +01:00
|
|
|
REFERENCES languages (id)
|
2020-10-27 14:49:18 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Subtitle lines
|
|
|
|
*/
|
2020-10-27 21:38:19 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS subtitle_lines
|
2020-10-27 14:49:18 +01:00
|
|
|
(
|
|
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
|
|
subtitle_id int NOT NULL,
|
|
|
|
dialog_line text NOT NULL,
|
|
|
|
time_code text NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (subtitle_id)
|
2020-10-27 21:38:19 +01:00
|
|
|
REFERENCES subtitles (id)
|
2020-10-27 14:49:18 +01:00
|
|
|
);
|