2024-01-25 06:56:58 +00:00
|
|
|
USE snippetbox;
|
|
|
|
|
|
|
|
CREATE TABLE snippets (
|
|
|
|
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
|
|
|
title VARCHAR(100) NOT NULL,
|
|
|
|
content TEXT NOT NULL,
|
|
|
|
created DATETIME NOT NULL,
|
|
|
|
expires DATETIME NOT NULL
|
|
|
|
);
|
|
|
|
|
2024-01-25 20:41:08 +00:00
|
|
|
CREATE USER 'web';
|
|
|
|
GRANT SELECT, INSERT, UPDATE, DELETE ON snippetbox.* TO 'web' IDENTIFIED BY 'dbpass';
|
2024-01-25 06:56:58 +00:00
|
|
|
|
|
|
|
CREATE INDEX idx_snippets_created ON snippets(created);
|
2024-02-07 05:06:48 +00:00
|
|
|
|
|
|
|
CREATE TABLE sessions (
|
|
|
|
token CHAR(43) PRIMARY KEY,
|
|
|
|
data BLOB NOT NULL,
|
|
|
|
expiry TIMESTAMP(6) NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX sessions_expiry_idx on sessions(expiry);
|
2024-02-07 19:07:29 +00:00
|
|
|
|
|
|
|
CREATE TABLE users (
|
|
|
|
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
2024-02-07 23:15:54 +00:00
|
|
|
username VARCHAR(255) NOT NULL,
|
|
|
|
email VARCHAR(255) NOT NULL,
|
|
|
|
hashed_password CHAR(60) NOT NULL,
|
2024-02-07 23:54:12 +00:00
|
|
|
created DATETIME NOT NULL
|
2024-02-07 23:15:54 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
ALTER TABLE users ADD CONSTRAINT users_uc_email UNIQUE (email);
|