generated from jric11/baseProject
ChatGPT's update to harden software and run db updates.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
CREATE TABLE IF NOT EXISTS club_invitations (
|
||||
invitation_serial BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
club_serial BIGINT UNSIGNED NOT NULL,
|
||||
invite_email VARCHAR(100) NOT NULL,
|
||||
membership_role ENUM('member','administrator') NOT NULL DEFAULT 'member',
|
||||
invited_by BIGINT UNSIGNED NOT NULL,
|
||||
invitation_status ENUM('pending','accepted','revoked') NOT NULL DEFAULT 'pending',
|
||||
expires_at DATETIME NOT NULL,
|
||||
sent_at DATETIME NOT NULL,
|
||||
accepted_at DATETIME NULL,
|
||||
UNIQUE KEY (club_serial,invite_email),
|
||||
FOREIGN KEY (club_serial) REFERENCES clubs(club_serial) ON DELETE RESTRICT,
|
||||
FOREIGN KEY (invited_by) REFERENCES users(user_serial) ON DELETE RESTRICT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
CREATE TABLE IF NOT EXISTS club_tickets (
|
||||
ticket_serial BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
club_serial BIGINT UNSIGNED NOT NULL,
|
||||
user_serial BIGINT UNSIGNED NOT NULL,
|
||||
subject VARCHAR(200) NOT NULL,
|
||||
ticket_status ENUM('open','closed') NOT NULL DEFAULT 'open',
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX (club_serial,user_serial,ticket_serial),
|
||||
FOREIGN KEY (club_serial) REFERENCES clubs(club_serial) ON DELETE RESTRICT,
|
||||
FOREIGN KEY (user_serial) REFERENCES users(user_serial) ON DELETE RESTRICT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
CREATE TABLE IF NOT EXISTS club_ticket_messages (
|
||||
message_serial BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
ticket_serial BIGINT UNSIGNED NOT NULL,
|
||||
author_serial BIGINT UNSIGNED NOT NULL,
|
||||
message_text TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (ticket_serial) REFERENCES club_tickets(ticket_serial) ON DELETE RESTRICT,
|
||||
FOREIGN KEY (author_serial) REFERENCES users(user_serial) ON DELETE RESTRICT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE IF NOT EXISTS user_mfa (
|
||||
user_serial BIGINT UNSIGNED NOT NULL PRIMARY KEY,
|
||||
secret_cipher TEXT NOT NULL,
|
||||
last_counter BIGINT NOT NULL DEFAULT -1,
|
||||
FOREIGN KEY (user_serial) REFERENCES users(user_serial) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
CREATE TABLE IF NOT EXISTS mfa_recovery (
|
||||
user_serial BIGINT UNSIGNED NOT NULL,
|
||||
code_hash CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
||||
PRIMARY KEY(user_serial,code_hash),
|
||||
FOREIGN KEY (user_serial) REFERENCES users(user_serial) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
CREATE TABLE IF NOT EXISTS club_resource_usage (
|
||||
club_serial BIGINT UNSIGNED NOT NULL,
|
||||
resource_name VARCHAR(32) NOT NULL,
|
||||
window_started DATETIME NOT NULL,
|
||||
used_count INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY(club_serial,resource_name),
|
||||
FOREIGN KEY (club_serial) REFERENCES clubs(club_serial) ON DELETE RESTRICT
|
||||
) ENGINE=InnoDB;
|
||||
Reference in New Issue
Block a user