Files
gander/web_server/database/users.sql
Chris-1010 6586506c97 MAJOR Fix: Resolved API Request Delays;
Feat: Added a dev test account to users for expedited login;
Refactor: Improve socket connection handling and add logging for API request duration & update to ListRow key generation for improved uniqueness;
Feat: Made it so streams with no set thumbnail use their category's thumbnail;
Minor Fix: Corrections to db recommendation methods;
2025-01-30 03:53:33 +00:00

63 lines
1.8 KiB
SQL

DROP TABLE IF EXISTS users;
CREATE TABLE users
(
user_id INTEGER PRIMARY KEY AUTOINCREMENT,
username VARCHAR(50) NOT NULL,
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),
current_stream_title VARCHAR(100),
current_selected_category_id INTEGER
);
SELECT * FROM users;
DROP TABLE IF EXISTS follows;
CREATE TABLE follows
(
user_id INTEGER NOT NULL,
followed_id INTEGER NOT NULL,
since DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, followed_id),
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY (followed_id) REFERENCES users(user_id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS user_preferences;
CREATE TABLE user_preferences
(
user_id INT NOT NULL,
category_id INT NOT NULL,
favourability INT NOT NULL DEFAULT 0,
PRIMARY KEY (user_id, category_id),
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY (category_id) REFERENCES categories(category_id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS subscribes;
CREATE TABLE subscribes
(
user_id INTEGER NOT NULL,
subscribed_id INTEGER NOT NULL,
since DATETIME NOT NULL,
expires DATETIME NOT NULL,
PRIMARY KEY (user_id),
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY (subscribed_id) REFERENCES users(user_id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS followed_categories;
CREATE TABLE followed_categories
(
user_id INTEGER NOT NULL,
category_id INTEGER NOT NULL,
PRIMARY KEY (user_id, category_id),
FOREIGN KEY(user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY(category_id) REFERENCES categories(category_id) ON DELETE CASCADE
);