CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE TABLE IF NOT EXISTS files (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name TEXT NOT NULL,
  description TEXT,
  mimetype TEXT NOT NULL,
  size INTEGER NOT NULL,
  blake2 BYTEA NOT NULL UNIQUE,
  created TIMESTAMP DEFAULT NOW() NOT NULL,
  updated TIMESTAMP DEFAULT NOW() NOT NULL
);

CREATE TABLE IF NOT EXISTS processing_jobs (
  id SERIAL PRIMARY KEY,
  file_id UUID REFERENCES files (id),
  created TIMESTAMP DEFAULT NOW(),
  started TIMESTAMP,
  completed TIMESTAMP,
  status TEXT,
  job_type TEXT
);
