From 2485133661f83a964c321e712174fe06ef96e916 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Wed, 14 Sep 2022 16:54:38 +0200 Subject: [PATCH] Maybe final DB table --- database/migrations/0001-2022-08-31.sql | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/database/migrations/0001-2022-08-31.sql b/database/migrations/0001-2022-08-31.sql index fe6db1a..d075af6 100644 --- a/database/migrations/0001-2022-08-31.sql +++ b/database/migrations/0001-2022-08-31.sql @@ -13,29 +13,31 @@ CREATE TABLE IF NOT EXISTS "dispense"( ); -- Contenuto caricato -CREATE TABLE IF NOT EXISTS "uploaded_contents"( +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, - "hash" TEXT NOT NULL + "file" TEXT NOT NULL, + FOREIGN KEY (dispensa_id) REFERENCES dispense(id) ); -- Contenuti con hash approvati -CREATE TABLE IF NOT EXISTS "hash_approvals"( +CREATE TABLE IF NOT EXISTS "file_approvals"( "id" TEXT NOT NULL PRIMARY KEY, - "created_at" TEXT NOT NULL, - "owner_id" TEXT NOT NULL, - "hash" TEXT NOT NULL + "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) ); --- 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 -); +-- 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 @@ -44,5 +46,6 @@ CREATE TABLE IF NOT EXISTS "hash_rejections"( -- Tags per le dispense CREATE TABLE IF NOT EXISTS "tags"( "dispensa_id" TEXT NOT NULL, - "tags" TEXT NOT NULL + "name" TEXT NOT NULL, + FOREIGN KEY (dispensa_id) REFERENCES dispense(id) );