Add users_subscribed table.

This commit is contained in:
Kavin 2023-08-14 08:32:26 +01:00
parent 8c52d0eb28
commit b0a97faf4f
No known key found for this signature in database
GPG key ID: 6E4598CA5C92C41F
2 changed files with 23 additions and 0 deletions

View file

@ -20,3 +20,14 @@ CREATE TABLE IF NOT EXISTS videos (
);
--rollback DROP TABLE IF EXISTS videos;
CREATE TABLE IF NOT EXISTS users_subscribed (
subscriber INT8 NOT NULL,
channel VARCHAR(24) NOT NULL,
CONSTRAINT users_subscribed_pkey PRIMARY KEY (subscriber ASC, channel ASC) USING HASH,
CONSTRAINT fk_subscriber_users FOREIGN KEY (subscriber) REFERENCES users(id),
INDEX users_subscribed_subscriber_idx (subscriber ASC),
INDEX users_subscribed_channel_idx (channel ASC)
);
--rollback DROP TABLE IF EXISTS users_subscribed;

View file

@ -20,3 +20,15 @@ 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;
CREATE TABLE IF NOT EXISTS users_subscribed (
subscriber INT8 NOT NULL,
channel VARCHAR(24) NOT NULL,
CONSTRAINT users_subscribed_pkey PRIMARY KEY (subscriber, channel),
CONSTRAINT fk_subscriber_users FOREIGN KEY (subscriber) REFERENCES users(id)
);
CREATE INDEX IF NOT EXISTS users_subscribed_subscriber_idx ON users_subscribed (subscriber ASC);
CREATE INDEX IF NOT EXISTS users_subscribed_channel_idx ON users_subscribed (channel ASC);
--rollback DROP TABLE IF EXISTS users_subscribed;