Implement videos table.

This commit is contained in:
Kavin 2023-08-14 08:24:53 +01:00
parent 8258468f7b
commit 8c52d0eb28
No known key found for this signature in database
GPG Key ID: 6E4598CA5C92C41F
3 changed files with 38 additions and 2 deletions

View File

@ -1,3 +1,22 @@
CREATE INDEX IF NOT EXISTS users_session_id_idx ON users (session_id ASC) STORING (password, username); CREATE INDEX IF NOT EXISTS users_session_id_idx ON users (session_id ASC) STORING (password, username);
--rollback DROP INDEX IF EXISTS users_session_id_idx; --rollback DROP INDEX IF EXISTS users_session_id_idx;
CREATE TABLE IF NOT EXISTS videos (
id VARCHAR(16) NOT NULL UNIQUE,
duration INT8 NULL,
thumbnail VARCHAR(400) NULL,
title VARCHAR(120) NULL,
uploaded INT8 NULL,
views INT8 NULL,
uploader_id VARCHAR(24) NOT NULL,
is_short BOOL NOT NULL DEFAULT false,
CONSTRAINT videos_pkey PRIMARY KEY (id ASC, uploader_id ASC) USING HASH,
CONSTRAINT fk_videos_channels_uploader_id FOREIGN KEY (uploader_id) REFERENCES channels(uploader_id),
INDEX videos_id_idx (id ASC),
INDEX video_uploaded_idx (uploaded ASC) USING HASH,
INDEX video_uploader_id_idx (uploader_id ASC) STORING (duration, thumbnail, title, uploaded, views, is_short),
UNIQUE INDEX videos_id_key (id ASC) STORING (duration, thumbnail, title, uploaded, views, is_short)
);
--rollback DROP TABLE IF EXISTS videos;

View File

@ -1,3 +1,22 @@
CREATE INDEX IF NOT EXISTS users_session_id_idx ON users (session_id ASC); CREATE INDEX IF NOT EXISTS users_session_id_idx ON users (session_id ASC);
--rollback DROP INDEX IF EXISTS users_session_id_idx; --rollback DROP INDEX IF EXISTS users_session_id_idx;
CREATE TABLE IF NOT EXISTS videos (
id VARCHAR(16) NOT NULL UNIQUE,
duration INT8 NULL,
thumbnail VARCHAR(400) NULL,
title VARCHAR(120) NULL,
uploaded INT8 NULL,
views INT8 NULL,
uploader_id VARCHAR(24) NOT NULL,
is_short BOOL NOT NULL DEFAULT false,
CONSTRAINT videos_pkey PRIMARY KEY (id, uploader_id),
CONSTRAINT fk_videos_channels_uploader_id FOREIGN KEY (uploader_id) REFERENCES channels(uploader_id)
);
CREATE UNIQUE INDEX IF NOT EXISTS videos_id_idx ON videos (id ASC);
CREATE INDEX IF NOT EXISTS video_uploaded_idx ON videos (uploaded ASC);
CREATE INDEX IF NOT EXISTS video_uploader_id_idx ON videos (uploader_id ASC);
--rollback DROP TABLE IF EXISTS videos;

View File

@ -10,7 +10,6 @@ DROP INDEX IF EXISTS users_id_idx;
CREATE INDEX IF NOT EXISTS username_idx ON users (username ASC); CREATE INDEX IF NOT EXISTS username_idx ON users (username ASC);
--rollback DROP INDEX IF EXISTS username_idx;
--rollback DROP TABLE IF EXISTS users; --rollback DROP TABLE IF EXISTS users;
CREATE TABLE IF NOT EXISTS channels ( CREATE TABLE IF NOT EXISTS channels (
@ -23,5 +22,4 @@ CREATE TABLE IF NOT EXISTS channels (
CREATE INDEX IF NOT EXISTS channels_uploader_idx ON channels (uploader ASC); CREATE INDEX IF NOT EXISTS channels_uploader_idx ON channels (uploader ASC);
--rollback DROP INDEX IF EXISTS channels_uploader_idx;
--rollback DROP TABLE IF EXISTS channels; --rollback DROP TABLE IF EXISTS channels;