2023-02-20 08:43:14 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')),
|
|
|
|
username TEXT UNIQUE,
|
|
|
|
signupid INTEGER,
|
|
|
|
state TEXT,
|
|
|
|
admin INTEGER DEFAULT FALSE,
|
|
|
|
|
|
|
|
FOREIGN KEY (signupid) REFERENCES signups(signupid)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS emails (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
address TEXT UNIQUE,
|
|
|
|
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,
|
2023-02-24 20:55:16 +00:00
|
|
|
author INTEGER,
|
|
|
|
content TEXT,
|
2023-02-20 08:43:14 +00:00
|
|
|
created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')),
|
|
|
|
|
|
|
|
FOREIGN KEY (adminid) REFERENCES users(adminid)
|
|
|
|
);
|