CREATE TABLE IF NOT EXISTS users (
	id       VARCHAR PRIMARY KEY,
	username VARCHAR NOT NULL,
	email    VARCHAR NOT NULL,
	passwd   VARCHAR NOT NULL,
	level    INT NOT NULL
);

CREATE TABLE IF NOT EXISTS tokens (
	token    VARCHAR PRIMARY KEY,
	user_id  VARCHAR
);

create table if not exists applications (
	id           text primary key,
	url          text not null,
	original_url text,
	unique_url   text,
    company      text,
    recruiter    text,
	title        text,
    mesasge      text default '',
	user_id      text,
	extra_data   text,
	status       integer
);

create table if not exists views (
    id             text primary key,
    application_id text not null,
    time           timestamp default current_timestamp
);

create table if not exists flair (
	id          text primary key,
	user_id     text not null,
	color       text default '#ff0000',
	name        text default 'New Flair',
	expr        text default 'flair',
	description text default ''
);

create table if not exists flair_link (
	id             text primary key,
	application_id text not null,
	flair_id       text not null
);
