forked from tildetown/town
43 lines
1.1 KiB
SQL
43 lines
1.1 KiB
SQL
CREATE TABLE IF NOT EXISTS users (
|
|
id INTEGER PRIMARY KEY,
|
|
created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')),
|
|
username TEXT UNIQUE,
|
|
state TEXT,
|
|
admin INTEGER DEFAULT 0
|
|
);
|
|
|
|
-- TODO address /should/ be unique but leaving it duplicable for now since i can think of some cases where there might be >1 account for the same human
|
|
CREATE TABLE IF NOT EXISTS emails (
|
|
id INTEGER PRIMARY KEY,
|
|
address TEXT,
|
|
userid INTEGER,
|
|
|
|
FOREIGN KEY (userid) REFERENCES users(userid)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS user_notes (
|
|
noteid INTEGER,
|
|
userid INTEGER,
|
|
|
|
PRIMARY KEY (noteid, userid),
|
|
FOREIGN KEY (noteid) REFERENCES notes(noteid),
|
|
FOREIGN KEY (userid) REFERENCES users(userid)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS notes (
|
|
id INTEGER PRIMARY KEY,
|
|
author INTEGER,
|
|
content TEXT,
|
|
created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')),
|
|
|
|
FOREIGN KEY (author) REFERENCES users(author)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS auth_codes (
|
|
id INTEGER PRIMARY KEY,
|
|
created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')),
|
|
code TEXT,
|
|
email TEXT,
|
|
used INTEGER DEFAULT 0
|
|
);
|