hackathon/sql/schema.sql

25 lines
641 B
MySQL

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,
completed BOOLEAN NOT NULL,
created_at DATETIME NOT NULL
);
CREATE TABLE user_info (
user_id TEXT NOT NULL PRIMARY KEY REFERENCES users (id),
grade_level INTEGER NOT NULL,
teacher BOOLEAN NOT NULL,
admin BOOLEAN 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);