
-- 
-- Entities
--

-- Dispense
CREATE TABLE IF NOT EXISTS "dispense"(
    "id"            TEXT NOT NULL PRIMARY KEY,
    "created_at"    TEXT NOT NULL,
    "owner_id"      TEXT NOT NULL,
    "title"         TEXT NOT NULL,
    "description"   TEXT NOT NULL
);

-- Contenuto caricato
CREATE TABLE IF NOT EXISTS "uploaded_contents"(
    "id"            TEXT NOT NULL PRIMARY KEY,
    "created_at"    TEXT NOT NULL,
    "owner_id"      TEXT NOT NULL,
    "dispensa_id"   TEXT NOT NULL,
    "hash"          TEXT NOT NULL
);

-- Contenuti con hash approvati
CREATE TABLE IF NOT EXISTS "hash_approvals"(
    "id"            TEXT NOT NULL PRIMARY KEY,
    "created_at"    TEXT NOT NULL,
    "owner_id"      TEXT NOT NULL,
    "hash"          TEXT NOT NULL
);

-- Contenuti con hash rifiutati
CREATE TABLE IF NOT EXISTS "hash_rejections"(
    "id"            TEXT NOT NULL PRIMARY KEY,
    "created_at"    TEXT NOT NULL,
    "owner_id"      TEXT NOT NULL,
    "hash"          TEXT NOT NULL
);

-- 
-- Relations
-- 

-- Tags per le dispense
CREATE TABLE IF NOT EXISTS "tags"(
    "dispensa_id" TEXT NOT NULL,
    "tags" TEXT NOT NULL
);
