Add scouthub-eventi-be

This commit is contained in:
Lorenzo Sanesi
2026-07-25 11:59:25 +02:00
parent 9ceb05cda2
commit 7e0544c5ab
36 changed files with 7776 additions and 0 deletions
@@ -0,0 +1,42 @@
-- CreateTable
CREATE TABLE "evento" (
"id" TEXT NOT NULL,
"org_id" TEXT NOT NULL,
"branca_id" TEXT NOT NULL,
"parent_id" TEXT,
"titolo" TEXT NOT NULL,
"descrizione" TEXT,
"data_inizio" TIMESTAMP(3) NOT NULL,
"data_fine" TIMESTAMP(3) NOT NULL,
"tipo" TEXT NOT NULL,
"location" TEXT,
"creato_da" TEXT NOT NULL,
"creato_il" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "evento_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "risorsa_collegata" (
"id" TEXT NOT NULL,
"evento_id" TEXT NOT NULL,
"tipo_risorsa" TEXT NOT NULL,
"risorsa_id" TEXT NOT NULL,
"servizio_origine" TEXT NOT NULL,
"metadata" JSONB,
"creato_il" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "risorsa_collegata_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "evento_org_id_branca_id_data_inizio_idx" ON "evento"("org_id", "branca_id", "data_inizio");
-- CreateIndex
CREATE INDEX "evento_parent_id_idx" ON "evento"("parent_id");
-- AddForeignKey
ALTER TABLE "evento" ADD CONSTRAINT "evento_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "evento"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "risorsa_collegata" ADD CONSTRAINT "risorsa_collegata_evento_id_fkey" FOREIGN KEY ("evento_id") REFERENCES "evento"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
+46
View File
@@ -0,0 +1,46 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Evento {
id String @id @default(uuid())
orgId String @map("org_id")
brancaId String @map("branca_id")
parentId String? @map("parent_id")
titolo String
descrizione String?
dataInizio DateTime @map("data_inizio")
dataFine DateTime @map("data_fine")
tipo String
location String?
creatoDa String @map("creato_da")
creatoIl DateTime @default(now()) @map("creato_il")
parent Evento? @relation("EventoParent", fields: [parentId], references: [id], onDelete: Cascade)
children Evento[] @relation("EventoParent")
risorseCollegate RisorsaCollegata[]
@@index([orgId, brancaId, dataInizio])
@@index([parentId])
@@map("evento")
}
model RisorsaCollegata {
id String @id @default(uuid())
eventoId String @map("evento_id")
tipoRisorsa String @map("tipo_risorsa")
risorsaId String @map("risorsa_id")
servizioOrigine String @map("servizio_origine")
metadata Json?
creatoIl DateTime @default(now()) @map("creato_il")
evento Evento @relation(fields: [eventoId], references: [id], onDelete: Cascade)
@@map("risorsa_collegata")
}