CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

CREATE TABLE users (
	uuid UUID NOT NULL PRIMARY KEY DEFAULT (uuid_generate_v4()),
	name VARCHAR(100) NOT NULL,
	email VARCHAR(255) NOT NULL UNIQUE,
	password_hash VARCHAR(100) NOT NULL,
	session_epoch TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
	created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
	updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);


CREATE TABLE sessions (
	jti UUID NOT NULL PRIMARY KEY DEFAULT (uuid_generate_v4()),
	uuid UUID NOT NULL REFERENCES users ON DELETE CASCADE
);
