Buckler/buckler.sql

54 lines
1.6 KiB
MySQL
Raw Normal View History

2019-09-15 19:40:58 -04:00
CREATE TABLE IF NOT EXISTS user_info (
id SERIAL PRIMARY KEY,
username TEXT NOT NULL,
email TEXT NOT NULL,
2019-09-19 20:49:40 -04:00
password_hash TEXT,
date_created TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
active BOOLEAN NOT NULL DEFAULT FALSE,
2019-09-24 19:34:20 -04:00
admin BOOLEAN NOT NULL DEFAULT FALSE,
passwordless BOOLEAN NOT NULL DEFAULT FALSE
2019-09-15 19:40:58 -04:00
);
CREATE TABLE IF NOT EXISTS user_session (
2019-09-16 20:18:50 -04:00
user_id INTEGER references user_info(id) ON DELETE CASCADE,
2019-09-15 19:40:58 -04:00
id TEXT PRIMARY KEY,
2019-09-16 20:18:50 -04:00
ip_address INET NOT NULL,
date_created TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
2019-09-19 20:49:40 -04:00
expires TIMESTAMP WITH TIME ZONE DEFAULT NOW() + INTERVAL '30 DAYS',
2019-09-16 20:18:50 -04:00
last_used TIMESTAMP WITH TIME ZONE DEFAULT NOW()
2019-09-15 19:40:58 -04:00
);
2019-09-19 20:49:40 -04:00
CREATE TABLE IF NOT EXISTS invite (
email TEXT PRIMARY KEY,
token TEXT NOT NULL,
date_created TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
expires TIMESTAMP WITH TIME ZONE DEFAULT NOW() + INTERVAL '24 HOURS'
);
CREATE TABLE IF NOT EXISTS email_confirmation (
user_id INTEGER PRIMARY KEY references user_info(id) ON DELETE CASCADE,
token TEXT NOT NULL,
date_created TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS app_info (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
url TEXT NOT NULL,
key_hash TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS app_user (
user_id INTEGER references user_info(id) ON DELETE CASCADE,
app_id INTEGER references app_info(id) ON DELETE CASCADE,
2019-09-25 19:46:57 -04:00
session_data JSON DEFAULT '{}',
2019-09-19 20:49:40 -04:00
PRIMARY KEY (user_id, app_id)
);
2019-09-24 19:34:20 -04:00
CREATE TABLE IF NOT EXISTS user_credential (
id SERIAL PRIMARY KEY,
user_id INTEGER references user_info(id) ON DELETE CASCADE,
nick TEXT NOT NULL,
credential BYTEA NOT NULL
);