UPDATE: Began on removing streamers table, and replacing the corresponding code, NOT TESTED (if it's too messy to work with then rollback)

This commit is contained in:
ThisBirchWood
2025-01-28 11:01:06 +00:00
parent 46a8895398
commit 13d7351588
7 changed files with 51 additions and 76 deletions

Binary file not shown.

View File

@@ -38,7 +38,7 @@ CREATE TABLE categories
DROP TABLE IF EXISTS streams;
CREATE TABLE streams
(
streamer_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
stream_id INTEGER NOT NULL,
title TEXT NOT NULL,
start_time DATETIME NOT NULL,
@@ -46,18 +46,7 @@ CREATE TABLE streams
isLive BOOLEAN NOT NULL DEFAULT 0,
vod_id INTEGER,
category_id NOT NULL,
PRIMARY KEY (streamer_id, stream_id),
PRIMARY KEY (user_id, stream_id),
FOREIGN KEY (category_id) REFERENCES categories(category_id) ON DELETE CASCADE,
FOREIGN KEY (streamer_id) REFERENCES streamers(user_id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS streamers;
CREATE TABLE streamers
(
user_id INTEGER PRIMARY KEY NOT NULL,
streamer_id INTEGER NOT NULL,
since DATETIME,
isPartnered BOOLEAN NOT NULL DEFAULT 0,
stream_key VARCHAR(60) NOT NULL,
FOREIGN KEY(user_id) REFERENCES users(user_id) ON DELETE CASCADE
);
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
);

View File

@@ -9,6 +9,8 @@ CREATE TABLE users
password VARCHAR(256) NOT NULL,
email VARCHAR(128) NOT NULL,
num_followers INTEGER NOT NULL,
stream_key VARCHAR(60) NOT NULL,
is_partnered BOOLEAN NOT NULL DEFAULT 0,
bio VARCHAR(1024)
);
@@ -18,11 +20,11 @@ DROP TABLE IF EXISTS follows;
CREATE TABLE follows
(
user_id INTEGER NOT NULL,
streamer_id INTEGER NOT NULL,
followed_id INTEGER NOT NULL,
since DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, streamer_id),
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY (streamer_id) REFERENCES streamers(streamer_id) ON DELETE CASCADE
FOREIGN KEY (followed_id) REFERENCES users(user_id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS user_preferences;
@@ -40,11 +42,11 @@ DROP TABLE IF EXISTS subscribes;
CREATE TABLE subscribes
(
user_id INTEGER NOT NULL,
streamer_id INTEGER NOT NULL,
subscribed_id INTEGER NOT NULL,
since DATETIME NOT NULL,
expires DATETIME NOT NULL,
PRIMARY KEY (user_id,streamer_id),
FOREIGN KEY(user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY(streamer_id) REFERENCES streamers(streamer_id) ON DELETE CASCADE
FOREIGN KEY(subscribed_id) REFERENCES users(user_id) ON DELETE CASCADE
);