CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE users ( id CHAR(22) NOT NULL PRIMARY KEY, username TEXT NOT NULL, host TEXT, display_name TEXT, email TEXT NOT NULL, password_hash TEXT NOT NULL, avatar_uri TEXT, bio TEXT, ); CREATE UNIQUE INDEX u_username_host ON users (username, host); CREATE UNIQUE INDEX u_username_local ON users (username) WHERE host IS NULL; --id UUID NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), CREATE TABLE keys ( key TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL );