hackathon/sql/schema.sql

41 lines
1.0 KiB
MySQL

2021-12-22 14:38:22 +07:00
PRAGMA journal_mode = WAL;
PRAGMA busy_timeout = 5000;
PRAGMA foreign_keys = ON;
CREATE TABLE users (
id TEXT PRIMARY KEY NOT NULL, -- supplied from google - not auto increment
name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE,
picture TEXT NOT NULL,
2021-12-22 14:38:22 +07:00
2021-09-30 10:32:18 +07:00
admin BOOLEAN NOT NULL,
created_at DATETIME NOT NULL
);
2021-12-22 14:38:22 +07:00
CREATE TABLE user_info (
user_id TEXT PRIMARY KEY NOT NULL REFERENCES users (id),
grade_level INTEGER NOT NULL,
skill_level INTEGER NOT NULL
);
CREATE TABLE tokens (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
token TEXT NOT NULL UNIQUE,
user_id TEXT NOT NULL REFERENCES users (id),
created_at DATETIME NOT NULL
);
CREATE INDEX user_tokens ON tokens(user_id);
2021-12-22 14:38:22 +07:00
CREATE TABLE question_attempt (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
user_id TEXT NOT NULL REFERENCES users (id),
question_id TEXT NOT NULL,
question_part INTEGER NOT NULL,
correct BOOLEAN NOT NULL,
points_awarded INTEGER NOT NULL,
answer TEXT NOT NULL,
2021-12-22 14:38:22 +07:00
code TEXT NOT NULL,
submitted_at DATETIME NOT NULL
);