-- -- 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 "uploads"( "id" TEXT NOT NULL PRIMARY KEY, "created_at" TEXT NOT NULL, "owner_id" TEXT NOT NULL, "dispensa_id" TEXT NOT NULL, "file" TEXT NOT NULL, FOREIGN KEY (dispensa_id) REFERENCES dispense(id) ); -- Contenuti con hash approvati CREATE TABLE IF NOT EXISTS "file_approvals"( "id" TEXT NOT NULL PRIMARY KEY, "created_at" TEXT NOT NULL, "owner_id" TEXT NOT NULL, -- Moderatore che ha creato questa approvazione "upload_id" TEXT NOT NULL, -- Upload a cui si riferisce questa approvazione "status" TEXT NOT NULL, -- Risultato dell'approvazione: "approved" | "rejected" FOREIGN KEY (upload_id) REFERENCES uploads(id) ); -- Download counter CREATE TABLE IF NOT EXISTS "downloads"( "dispensa_id" TEXT NOT NULL, "timestamp" TEXT NOT NULL, FOREIGN KEY (dispensa_id) REFERENCES dispense(id) ) -- -- Relations -- -- Tags per le dispense CREATE TABLE IF NOT EXISTS "tags"( "dispensa_id" TEXT NOT NULL, "name" TEXT NOT NULL, FOREIGN KEY (dispensa_id) REFERENCES dispense(id) );