diff --git a/microservices/creation_qcm/src/routes/CreationQcm.ts b/microservices/creation_qcm/src/routes/CreationQcm.ts index 71cd45e14c45c474891191521014eba38742dcc8..5a77950e8587df3f66113564e7a17e0f80754d07 100644 --- a/microservices/creation_qcm/src/routes/CreationQcm.ts +++ b/microservices/creation_qcm/src/routes/CreationQcm.ts @@ -9,172 +9,181 @@ import { MessageRoute } from './MessageRoute.js'; const router: express.Router = express.Router(); // router.use(verifyJWT) -// 🚀 Route pour créer un QCM router.post('/QCM', verifyJWT, async (req: express.Request, res: express.Response) => { console.log(`[LOG] Ajout QCM avec les données:`, req.body); - try { - const { qcm, idUser } = req.body; - if (!qcm || !idUser || !qcm["nomQcm"] || qcm["randomQuestion"] === undefined || qcm["tempsMax"] === undefined) { - console.error(`[ERROR] Paramètres manquants pour la création du QCM`); - return res.status(400).send({ error: MessageRoute.misPara }); - } - - const codeAcces: number = getRandomNumber(1000, 9999); - const qcmCreate = await db.qcmTable.create({ - data: { - nomQCM: qcm["nomQcm"], - codeAcces: codeAcces, - randomOrder: qcm["randomQuestion"], - temps: qcm["tempsMax"], - idUserCreator: idUser, - } - }); - - console.log(`[SUCCESS] QCM créé avec l'ID: ${qcmCreate.idQCM}`); - res.status(200).send({ id: qcmCreate.idQCM }); - - } catch (error) { - console.error(`[ERROR] Erreur lors de la création du QCM:`, error); - res.status(500).send({ error: MessageRoute.serverError }); + const { qcm, idUser } = req.body; + console.log(qcm, idUser, qcm["nomQcm"], qcm["randomQuestion"], qcm["tempsMax"]) + if (!qcm || !idUser || !qcm["nomQcm"] || qcm["randomQuestion"] === undefined || qcm["tempsMax"] === undefined) + { + res.status(400).send({ error: MessageRoute.misPara }); + return } + const codeAcces: number = getRandomNumber(1000, 9999); + const qcmCreate = await db.qcmTable.create({ + data: { + nomQCM : qcm["nomQcm"], + codeAcces : codeAcces, + randomOrder : qcm["randomQuestion"], + temps : qcm["tempsMax"], + idUserCreator : idUser, + } + }); + res.status(200).send({id: qcmCreate.idQCM}); }); - -// 🚀 Route pour mettre à jour un QCM router.put('/QCM', verifyJWT, async (req: express.Request, res: express.Response) => { - console.log(`[LOG] Mise à jour QCM avec les données:`, req.body); - try { - const { qcm } = req.body; - if (!qcm || !qcm["nomQcm"] || qcm["randomQuestion"] === undefined || qcm["tempsMax"] === undefined || qcm["idQcm"] === undefined) { - console.error(`[ERROR] Paramètres manquants pour la mise à jour du QCM`); - return res.status(400).send({ error: MessageRoute.misPara }); - } - - const infoQcm = await db.qcmTable.findFirst({ where: { idQCM: qcm["idQcm"] } }); - if (!infoQcm) { - console.error(`[ERROR] QCM introuvable avec l'ID: ${qcm["idQcm"]}`); - return res.status(404).send({ error: MessageRoute.qcmDoesntExist }); + console.log(`[LOG] Traitement de la création de QCM avec les données:`, req.body); + const { qcm } = req.body; + console.table(qcm) + if (!qcm || !qcm["nomQcm"] || qcm["randomQuestion"] === undefined || qcm["tempsMax"] === undefined || qcm["idQcm"] === undefined) + { + res.status(400).send({ error: MessageRoute.misPara }); + return + } + const infoQcm = await db.qcmTable.findFirst({ + where: { + idQCM: qcm["idQcm"], } - - checkUser(req, res, infoQcm.idUserCreator, "This is not your QCM"); - - const qcmUpdate = await db.qcmTable.update({ - where: { idQCM: qcm["idQcm"] }, - data: { - nomQCM: qcm["nomQcm"], - randomOrder: qcm["randomQuestion"], - temps: qcm["tempsMax"], - }, - }); - - console.log(`[SUCCESS] QCM mis à jour:`, qcmUpdate); - res.status(200).send(qcmUpdate); - } catch (error) { - console.error(`[ERROR] Erreur lors de la mise à jour du QCM:`, error); - res.status(500).send({ error: MessageRoute.serverError }); + }); + + if(!infoQcm) + { + res.status(404).send({ error: MessageRoute.qcmDoesntExist }); + return } + checkUser(req, res, infoQcm?.idUserCreator, "This is not your QCM"); + const qcmCreate = await db.qcmTable.update({ + where: { + idQCM: qcm["idQcm"] + }, + data: { + nomQCM : qcm["nomQcm"], + randomOrder : qcm["randomQuestion"], + temps : qcm["tempsMax"], + }, + }); + res.status(200).send(qcmCreate); }); -// 🚀 Route pour ajouter une question numérique router.post('/numeric_question', verifyJWT, async (req: express.Request, res: express.Response) => { console.log(`[LOG] Ajout de question numérique avec les données:`, req.body); - try { - const { question, idQcm } = req.body; - if (!idQcm || !question || !question["question"] || question["nbPtsNegatif"] === undefined || question["nbPtsPositif"] === undefined || question["valNum"] === undefined || question["position"] === undefined) { - console.error(`[ERROR] Paramètres manquants pour la question numérique`); - return res.status(400).send({ error: MessageRoute.misPara }); - } - - const infoQcm = await db.qcmTable.findFirst({ where: { idQCM: idQcm } }); - if (!infoQcm) { - console.error(`[ERROR] QCM introuvable avec l'ID: ${idQcm}`); - return res.status(404).send({ error: MessageRoute.qcmDoesntExist }); - } - - checkUser(req, res, infoQcm.idUserCreator, MessageRoute.cantCreate); - - const type = await db.type.findFirst({ where: { nomType: "numerique" } }); - if (!type) { - console.error(`[ERROR] Type 'numerique' introuvable`); - return res.status(500).send({ error: 'Server error' }); + const { question, idQcm } = req.body; + + console.log(question, idQcm); + if (!idQcm || !question || !question["question"] || question["nbPtsNegatif"] === undefined || question["nbPtsPositif"] === undefined || question["valNum"] === undefined || question["position"] === undefined) + { + res.status(400).send({ error: MessageRoute.misPara }); + return + } + const infoQcm = await db.qcmTable.findFirst({ + where: { + idQCM: idQcm } - - const questionCreate = await db.question.create({ - data: { - nbPtsNegatif: question["nbPtsNegatif"], - nbPtsPositif: question["nbPtsPositif"], - position: question["position"], - isMultiple: false, - question: question["question"], - idQCM: idQcm, - idType: type["idType"], - numeric: question["valNum"], - randomOrder: false, - } - }); - - console.log(`[SUCCESS] Question numérique créée avec l'ID: ${questionCreate.idQuestion}`); - res.status(200).send({ id: questionCreate.idQuestion }); - - } catch (error) { - console.error(`[ERROR] Erreur lors de la création de la question numérique:`, error); - res.status(500).send({ error: MessageRoute.serverError }); + }); + if(!infoQcm) + { + res.status(404).send({ error: MessageRoute.qcmDoesntExist }); + return + } + checkUser(req, res, infoQcm.idUserCreator, MessageRoute.cantCreate); + const type = await db.type.findFirst({ + where: { + nomType: "numerique" + }, + }); + if(!type) + { + res.status(500).send({ error: 'Server error' }); + return } + const qcmCreate = await db.question.create({ + data: { + nbPtsNegatif: question["nbPtsNegatif"], + nbPtsPositif: question["nbPtsPositif"], + position: question["position"], + isMultiple: false, + question: question["question"], + idQCM: idQcm, + idType: type["idType"], + numeric: question["valNum"], + randomOrder: false, + } + }); + res.status(200).send({id: qcmCreate.idQuestion}); }); - -// 🚀 Route pour ajouter une question vrai/faux router.post('/true_false_question', verifyJWT, async (req: express.Request, res: express.Response) => { console.log(`[LOG] Ajout question true_false avec les données:`, req.body); try { const { question, idQcm } = req.body; - if (!idQcm || !question || !question["question"] || question["nbPtsNegatif"] === undefined || question["nbPtsPositif"] === undefined || question["isVraiFaux"] === undefined || question["valVraiFaux"] === undefined) { - console.error(`[ERROR] Paramètres manquants pour la question vrai/faux`); - return res.status(400).send({ error: MessageRoute.misPara }); + console.table(req.body) + console.log(question, idQcm) + if (!idQcm || !question || !question["question"] || !question["nbPtsNegatif"] === undefined || !question["nbPtsPositif"] === undefined || question["isVraiFaux"] === undefined || question["valVraiFaux"] === undefined) { + res.status(400).send({ error: MessageRoute.misPara }); + return } - - const infoQcm = await db.qcmTable.findFirst({ where: { idQCM: idQcm } }); + + const infoQcm = await db.qcmTable.findFirst({ + where: { + idQCM: idQcm + } + }); + if (!infoQcm) { - console.error(`[ERROR] QCM introuvable avec l'ID: ${idQcm}`); - return res.status(404).send({ error: MessageRoute.qcmDoesntExist }); + res.status(400).send({ error:MessageRoute.qcmDoesntExist}); + return } - checkUser(req, res, infoQcm.idUserCreator, MessageRoute.cantCreate); - - const type = await db.type.findFirst({ where: { nomType: "vraiFaux" } }); + + const type = await db.type.findFirst({ + where: { + nomType: "vraiFaux" + } + }); + if (!type) { - console.error(`[ERROR] Type 'vraiFaux' introuvable`); - return res.status(500).send({ error: 'Server Problem: Type not found' }); + res.status(500).send({ error: 'Server Problem: Type not found' }); + return } - + + const questionCreate = await db.question.create({ - data: { - nbPtsNegatif: question["nbPtsNegatif"], - nbPtsPositif: question["nbPtsPositif"], - position: 0, - isMultiple: false, - question: question["question"], - idQCM: idQcm, - idType: type["idType"], - randomOrder: question["randomOrder"], - } + data: { + nbPtsNegatif: question["nbPtsNegatif"], + nbPtsPositif: question["nbPtsPositif"], + position: 0, + isMultiple: false, + question: question["question"], + idQCM: idQcm, + idType: type["idType"], + randomOrder: question["randomOrder"], + } }); - - console.log(`[SUCCESS] Question vrai/faux créée avec l'ID: ${questionCreate.idQuestion}`); - + + + if (!questionCreate) { + res.status(500).send({ error: 'Server Problem: Question creation failed' }); + return + } + + const idQuestion = questionCreate.idQuestion; + const choixData = [ - { nomChoix: "Vrai", isCorrect: question.valVraiFaux, idQuestion: questionCreate.idQuestion, position: 0 }, - { nomChoix: "Faux", isCorrect: !question.valVraiFaux, idQuestion: questionCreate.idQuestion, position: 1 } + { nomChoix: "Vrai", isCorrect: question.valVraiFaux, idQuestion: idQuestion, position: 0 }, + { nomChoix: "Faux", isCorrect: !question.valVraiFaux, idQuestion: idQuestion, position: 1 } ]; - - await db.choix.createMany({ data: choixData }); - - console.log(`[SUCCESS] Choix insérés pour la question ID: ${questionCreate.idQuestion}`); - res.status(200).send({ id: questionCreate.idQuestion }); - + + const choixCreate = await db.choix.createMany({ + data: choixData + }); + if(!choixCreate){ + res.status(500).send({ error: MessageRoute.serverError }); + return + } + + res.status(200).send({id: idQuestion}); } catch (error) { - console.error(`[ERROR] Erreur inattendue:`, error); res.status(500).send({ error: MessageRoute.serverError }); } }); diff --git a/microservices/helloworld/dockerfile b/microservices/helloworld/dockerfile index 17873a2f624f44c6da8565fb70447efb35388139..5ecf6a1dd5313d3ea89f871f700813ae6356ac21 100644 --- a/microservices/helloworld/dockerfile +++ b/microservices/helloworld/dockerfile @@ -4,13 +4,13 @@ FROM node:18 AS builder # Définir le répertoire de travail WORKDIR /app -# Copier le fichier package.json et package-lock.json +# Copier les fichiers package COPY package.json package-lock.json ./ # Installer les dépendances RUN npm install -# Copier tous les fichiers source +# Copier les fichiers sources COPY . . # Compiler le projet TypeScript @@ -19,23 +19,21 @@ RUN npm run build # Étape 2 : Image de production FROM node:18 -# Créer un répertoire de travail pour l'application +# Définir le répertoire de travail WORKDIR /app -# Copier les fichiers environnement -COPY .env .env - -# Copier les fichiers nécessaires du builder +# Copier les fichiers nécessaires depuis le builder COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/prisma ./prisma COPY package.json ./ +COPY .env .env COPY entrypoint.sh ./entrypoint.sh -# Ajouter les permissions pour le script d'entrée +# Donner les permissions nécessaires RUN chmod +x entrypoint.sh EXPOSE 30992 # Utilisation du script d'entrée -ENTRYPOINT ["sh", "./entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["sh", "./entrypoint.sh"] diff --git a/microservices/helloworld/entrypoint.sh b/microservices/helloworld/entrypoint.sh index a50235a3e4bbc3e94a56cc84a27d8963a65ef5e1..77471928f4c4680b33b032d99f35de1550eb2b74 100644 --- a/microservices/helloworld/entrypoint.sh +++ b/microservices/helloworld/entrypoint.sh @@ -1,10 +1,18 @@ #!/bin/sh echo "⏳ Attente de la base de données PostgreSQL..." -until npx prisma db push; do + +# Attente active que la base soit prête +until npx prisma migrate deploy; do >&2 echo "PostgreSQL non prêt - nouvelle tentative dans 2s..." sleep 2 done -echo "BDD prete - démarrage du serveur express avec routes de base" -exec npx dotenvx run -- npx nodemon dist/src/app.js +echo "✅ Base de données prête - Migrations appliquées" + +# Exécution du seed après les migrations +echo "🌱 Exécution du seed Prisma..." +npx prisma db seed + +echo "✅ Base de données initialisée - Démarrage du serveur Express..." +exec npx dotenvx run -- node dist/src/app.js diff --git a/microservices/helloworld/prisma/database.db b/microservices/helloworld/prisma/database.db deleted file mode 100644 index d43cbe19ddee87ab6f09e2644d0559a1d0a36e4f..0000000000000000000000000000000000000000 Binary files a/microservices/helloworld/prisma/database.db and /dev/null differ diff --git a/microservices/helloworld/prisma/migrations/20240417125028_database_creation/migration.sql b/microservices/helloworld/prisma/migrations/20240417125028_database_creation/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240417125028_database_creation/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240417125048_add_user_schema/migration.sql b/microservices/helloworld/prisma/migrations/20240417125048_add_user_schema/migration.sql deleted file mode 100644 index d8030354425fc9fc27d096fb567bcf6de66a85a2..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240417125048_add_user_schema/migration.sql +++ /dev/null @@ -1,14 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "name" TEXT, - "mail" TEXT, - "gitlabUsername" TEXT NOT NULL, - "deleted" BOOLEAN NOT NULL DEFAULT false -); - --- CreateIndex -CREATE UNIQUE INDEX "User_mail_key" ON "User"("mail"); - --- CreateIndex -CREATE UNIQUE INDEX "User_gitlabUsername_key" ON "User"("gitlabUsername"); diff --git a/microservices/helloworld/prisma/migrations/20240523145021_create_complete_database/migration.sql b/microservices/helloworld/prisma/migrations/20240523145021_create_complete_database/migration.sql deleted file mode 100644 index b6a8b802e05baff59c9845d34305d7782806b55e..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240523145021_create_complete_database/migration.sql +++ /dev/null @@ -1,48 +0,0 @@ --- CreateTable -CREATE TABLE "QCM" ( - "idQCM" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "nomQCM" TEXT NOT NULL, - "temps" TEXT NOT NULL, - "randomOrder" BOOLEAN NOT NULL -); - --- CreateTable -CREATE TABLE "Type" ( - "idType" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "nomType" TEXT NOT NULL -); - --- CreateTable -CREATE TABLE "Choix" ( - "idChoix" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "isCorrect" BOOLEAN NOT NULL, - "idQuestion" INTEGER NOT NULL, - CONSTRAINT "Choix_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" BOOLEAN, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QCM" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Reponse" ( - "idQuestion" INTEGER NOT NULL, - "idChoix" INTEGER NOT NULL, - "idUser" INTEGER NOT NULL, - "numeric" REAL, - - PRIMARY KEY ("idQuestion", "idChoix", "idUser"), - CONSTRAINT "Reponse_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Reponse_idChoix_fkey" FOREIGN KEY ("idChoix") REFERENCES "Choix" ("idChoix") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Reponse_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); diff --git a/microservices/helloworld/prisma/migrations/20240530082347_update_db/migration.sql b/microservices/helloworld/prisma/migrations/20240530082347_update_db/migration.sql deleted file mode 100644 index 60c86e8c93bf3e342bed7b5cc39c4a7e653d4b67..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240530082347_update_db/migration.sql +++ /dev/null @@ -1,30 +0,0 @@ -/* - Warnings: - - - Added the required column `codeAcces` to the `QCM` table without a default value. This is not possible if the table is not empty. - -*/ --- CreateTable -CREATE TABLE "Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QCM" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); - --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_QCM" ( - "idQCM" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "nomQCM" TEXT NOT NULL, - "temps" TEXT NOT NULL, - "randomOrder" BOOLEAN NOT NULL, - "codeAcces" INTEGER NOT NULL -); -INSERT INTO "new_QCM" ("idQCM", "nomQCM", "randomOrder", "temps") SELECT "idQCM", "nomQCM", "randomOrder", "temps" FROM "QCM"; -DROP TABLE "QCM"; -ALTER TABLE "new_QCM" RENAME TO "QCM"; -PRAGMA foreign_key_check("QCM"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240530082946_add_champs/migration.sql b/microservices/helloworld/prisma/migrations/20240530082946_add_champs/migration.sql deleted file mode 100644 index 2eb101b85823f301ea420072cfb0e4bdeae54b4d..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240530082946_add_champs/migration.sql +++ /dev/null @@ -1,24 +0,0 @@ -/* - Warnings: - - - Added the required column `feedback` to the `Participer` table without a default value. This is not possible if the table is not empty. - - Added the required column `note` to the `Participer` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QCM" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("idQCM", "idUser") SELECT "idQCM", "idUser" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240530151620_update/migration.sql b/microservices/helloworld/prisma/migrations/20240530151620_update/migration.sql deleted file mode 100644 index cd6e8980aed9710df93d3c881ea7ee0e687034ec..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240530151620_update/migration.sql +++ /dev/null @@ -1,20 +0,0 @@ -/* - Warnings: - - - Added the required column `nomChoix` to the `Choix` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Choix" ( - "idChoix" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "isCorrect" BOOLEAN NOT NULL, - "idQuestion" INTEGER NOT NULL, - "nomChoix" TEXT NOT NULL, - CONSTRAINT "Choix_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Choix" ("idChoix", "idQuestion", "isCorrect") SELECT "idChoix", "idQuestion", "isCorrect" FROM "Choix"; -DROP TABLE "Choix"; -ALTER TABLE "new_Choix" RENAME TO "Choix"; -PRAGMA foreign_key_check("Choix"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240530161440_/migration.sql b/microservices/helloworld/prisma/migrations/20240530161440_/migration.sql deleted file mode 100644 index ac44a9b444eac993806e94a4d9857f907108d419..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240530161440_/migration.sql +++ /dev/null @@ -1,53 +0,0 @@ -/* - Warnings: - - - You are about to drop the `QCM` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "QCM"; -PRAGMA foreign_keys=on; - --- CreateTable -CREATE TABLE "Qcm" ( - "idQCM" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "nomQCM" TEXT NOT NULL, - "temps" TEXT NOT NULL, - "randomOrder" BOOLEAN NOT NULL, - "codeAcces" INTEGER NOT NULL -); - --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" BOOLEAN, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "Qcm" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Question" ("idQCM", "idQuestion", "idType", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question") SELECT "idQCM", "idQuestion", "idType", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question" FROM "Question"; -DROP TABLE "Question"; -ALTER TABLE "new_Question" RENAME TO "Question"; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "Qcm" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "idQCM", "idUser", "note") SELECT "feedback", "idQCM", "idUser", "note" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Question"); -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240530162619_test/migration.sql b/microservices/helloworld/prisma/migrations/20240530162619_test/migration.sql deleted file mode 100644 index aa822b847d196e0ae648747c4467cb178a7b66ed..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240530162619_test/migration.sql +++ /dev/null @@ -1,53 +0,0 @@ -/* - Warnings: - - - You are about to drop the `Qcm` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "Qcm"; -PRAGMA foreign_keys=on; - --- CreateTable -CREATE TABLE "QcmTable" ( - "idQCM" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "nomQCM" TEXT NOT NULL, - "temps" TEXT NOT NULL, - "randomOrder" BOOLEAN NOT NULL, - "codeAcces" INTEGER NOT NULL -); - --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" BOOLEAN, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Question" ("idQCM", "idQuestion", "idType", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question") SELECT "idQCM", "idQuestion", "idType", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question" FROM "Question"; -DROP TABLE "Question"; -ALTER TABLE "new_Question" RENAME TO "Question"; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "idQCM", "idUser", "note") SELECT "feedback", "idQCM", "idUser", "note" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Question"); -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240606084017_c/migration.sql b/microservices/helloworld/prisma/migrations/20240606084017_c/migration.sql deleted file mode 100644 index dfcc3f5411436d2f59e98a1642390bc2d091f8dc..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240606084017_c/migration.sql +++ /dev/null @@ -1,37 +0,0 @@ -/* - Warnings: - - - Added the required column `heureDebut` to the `Participer` table without a default value. This is not possible if the table is not empty. - - Added the required column `position` to the `Choix` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - "heureDebut" TEXT NOT NULL, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "idQCM", "idUser", "note") SELECT "feedback", "idQCM", "idUser", "note" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -CREATE TABLE "new_Choix" ( - "idChoix" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "isCorrect" BOOLEAN NOT NULL, - "idQuestion" INTEGER NOT NULL, - "nomChoix" TEXT NOT NULL, - "position" INTEGER NOT NULL, - CONSTRAINT "Choix_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Choix" ("idChoix", "idQuestion", "isCorrect", "nomChoix") SELECT "idChoix", "idQuestion", "isCorrect", "nomChoix" FROM "Choix"; -DROP TABLE "Choix"; -ALTER TABLE "new_Choix" RENAME TO "Choix"; -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_key_check("Choix"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240606093824_relation_added/migration.sql b/microservices/helloworld/prisma/migrations/20240606093824_relation_added/migration.sql deleted file mode 100644 index 3419aa373f73c34a0ae0436d3fcbb56cd522840c..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240606093824_relation_added/migration.sql +++ /dev/null @@ -1,40 +0,0 @@ -/* - Warnings: - - - Added the required column `isMultiple` to the `Question` table without a default value. This is not possible if the table is not empty. - - Added the required column `idUserCreator` to the `QcmTable` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" BOOLEAN, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - "isMultiple" BOOLEAN NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Question" ("idQCM", "idQuestion", "idType", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question") SELECT "idQCM", "idQuestion", "idType", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question" FROM "Question"; -DROP TABLE "Question"; -ALTER TABLE "new_Question" RENAME TO "Question"; -CREATE TABLE "new_QcmTable" ( - "idQCM" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "nomQCM" TEXT NOT NULL, - "temps" TEXT NOT NULL, - "randomOrder" BOOLEAN NOT NULL, - "codeAcces" INTEGER NOT NULL, - "idUserCreator" INTEGER NOT NULL, - CONSTRAINT "QcmTable_idUserCreator_fkey" FOREIGN KEY ("idUserCreator") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_QcmTable" ("codeAcces", "idQCM", "nomQCM", "randomOrder", "temps") SELECT "codeAcces", "idQCM", "nomQCM", "randomOrder", "temps" FROM "QcmTable"; -DROP TABLE "QcmTable"; -ALTER TABLE "new_QcmTable" RENAME TO "QcmTable"; -PRAGMA foreign_key_check("Question"); -PRAGMA foreign_key_check("QcmTable"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240606094407_v/migration.sql b/microservices/helloworld/prisma/migrations/20240606094407_v/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240606094407_v/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240612164927_change_date_type/migration.sql b/microservices/helloworld/prisma/migrations/20240612164927_change_date_type/migration.sql deleted file mode 100644 index fa2acb9a6d9b15515be9fbda10eef0f74d217884..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240612164927_change_date_type/migration.sql +++ /dev/null @@ -1,24 +0,0 @@ -/* - Warnings: - - - You are about to alter the column `heureDebut` on the `Participer` table. The data in that column could be lost. The data in that column will be cast from `String` to `Int`. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - "heureDebut" INTEGER NOT NULL, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "heureDebut", "idQCM", "idUser", "note") SELECT "feedback", "heureDebut", "idQCM", "idUser", "note" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240612180153_change_temps_type/migration.sql b/microservices/helloworld/prisma/migrations/20240612180153_change_temps_type/migration.sql deleted file mode 100644 index 5e75a88d2d19a89b61a23bf1d15522f8157c83f8..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240612180153_change_temps_type/migration.sql +++ /dev/null @@ -1,22 +0,0 @@ -/* - Warnings: - - - You are about to alter the column `temps` on the `QcmTable` table. The data in that column could be lost. The data in that column will be cast from `String` to `Int`. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_QcmTable" ( - "idQCM" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "nomQCM" TEXT NOT NULL, - "temps" INTEGER NOT NULL, - "randomOrder" BOOLEAN NOT NULL, - "codeAcces" INTEGER NOT NULL, - "idUserCreator" INTEGER NOT NULL, - CONSTRAINT "QcmTable_idUserCreator_fkey" FOREIGN KEY ("idUserCreator") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_QcmTable" ("codeAcces", "idQCM", "idUserCreator", "nomQCM", "randomOrder", "temps") SELECT "codeAcces", "idQCM", "idUserCreator", "nomQCM", "randomOrder", "temps" FROM "QcmTable"; -DROP TABLE "QcmTable"; -ALTER TABLE "new_QcmTable" RENAME TO "QcmTable"; -PRAGMA foreign_key_check("QcmTable"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240613090400_add_has_finished/migration.sql b/microservices/helloworld/prisma/migrations/20240613090400_add_has_finished/migration.sql deleted file mode 100644 index 192dde7424ce7e356bf0f97cc7a7d6ce1bdcc32b..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613090400_add_has_finished/migration.sql +++ /dev/null @@ -1,19 +0,0 @@ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - "heureDebut" INTEGER NOT NULL, - "hasFinished" BOOLEAN NOT NULL DEFAULT false, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "heureDebut", "idQCM", "idUser", "note") SELECT "feedback", "heureDebut", "idQCM", "idUser", "note" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240613125037_change_numeric_type/migration.sql b/microservices/helloworld/prisma/migrations/20240613125037_change_numeric_type/migration.sql deleted file mode 100644 index db70c6b03e8f19f850bb3adfa4ec4cd8e659f5fd..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613125037_change_numeric_type/migration.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* - Warnings: - - - You are about to alter the column `numeric` on the `Question` table. The data in that column could be lost. The data in that column will be cast from `Boolean` to `Int`. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" INTEGER, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - "isMultiple" BOOLEAN NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Question" ("idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question") SELECT "idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question" FROM "Question"; -DROP TABLE "Question"; -ALTER TABLE "new_Question" RENAME TO "Question"; -PRAGMA foreign_key_check("Question"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240613130357_test/migration.sql b/microservices/helloworld/prisma/migrations/20240613130357_test/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613130357_test/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240613135314_/migration.sql b/microservices/helloworld/prisma/migrations/20240613135314_/migration.sql deleted file mode 100644 index f0ced18d1814307ba106a14d93c665c214a38188..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613135314_/migration.sql +++ /dev/null @@ -1,25 +0,0 @@ -/* - Warnings: - - - The primary key for the `Reponse` table will be changed. If it partially fails, the table could be left without primary key constraint. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Reponse" ( - "idQuestion" INTEGER NOT NULL, - "idChoix" INTEGER, - "idUser" INTEGER NOT NULL, - "numeric" REAL, - - PRIMARY KEY ("idQuestion", "idUser"), - CONSTRAINT "Reponse_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Reponse_idChoix_fkey" FOREIGN KEY ("idChoix") REFERENCES "Choix" ("idChoix") ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT "Reponse_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Reponse" ("idChoix", "idQuestion", "idUser", "numeric") SELECT "idChoix", "idQuestion", "idUser", "numeric" FROM "Reponse"; -DROP TABLE "Reponse"; -ALTER TABLE "new_Reponse" RENAME TO "Reponse"; -CREATE UNIQUE INDEX "Reponse_idQuestion_idUser_idChoix_key" ON "Reponse"("idQuestion", "idUser", "idChoix"); -PRAGMA foreign_key_check("Reponse"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240613135344_test2/migration.sql b/microservices/helloworld/prisma/migrations/20240613135344_test2/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613135344_test2/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240613145516_test3/migration.sql b/microservices/helloworld/prisma/migrations/20240613145516_test3/migration.sql deleted file mode 100644 index 1ed20e0ed62fa1741a19c806a5200a85d2a31155..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613145516_test3/migration.sql +++ /dev/null @@ -1,25 +0,0 @@ -/* - Warnings: - - - The primary key for the `Reponse` table will be changed. If it partially fails, the table could be left without primary key constraint. - - Added the required column `idReponse` to the `Reponse` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Reponse" ( - "idReponse" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "idQuestion" INTEGER NOT NULL, - "idChoix" INTEGER, - "idUser" INTEGER NOT NULL, - "numeric" REAL, - CONSTRAINT "Reponse_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Reponse_idChoix_fkey" FOREIGN KEY ("idChoix") REFERENCES "Choix" ("idChoix") ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT "Reponse_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Reponse" ("idChoix", "idQuestion", "idUser", "numeric") SELECT "idChoix", "idQuestion", "idUser", "numeric" FROM "Reponse"; -DROP TABLE "Reponse"; -ALTER TABLE "new_Reponse" RENAME TO "Reponse"; -CREATE UNIQUE INDEX "Reponse_idQuestion_idUser_idChoix_key" ON "Reponse"("idQuestion", "idUser", "idChoix"); -PRAGMA foreign_key_check("Reponse"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240613150814_es/migration.sql b/microservices/helloworld/prisma/migrations/20240613150814_es/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613150814_es/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240613154612_add_some_action/migration.sql b/microservices/helloworld/prisma/migrations/20240613154612_add_some_action/migration.sql deleted file mode 100644 index 1e72d45c59d5f3f7861d60a7687b13854297f001..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613154612_add_some_action/migration.sql +++ /dev/null @@ -1,30 +0,0 @@ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Choix" ( - "idChoix" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "isCorrect" BOOLEAN NOT NULL, - "idQuestion" INTEGER NOT NULL, - "nomChoix" TEXT NOT NULL, - "position" INTEGER NOT NULL, - CONSTRAINT "Choix_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO "new_Choix" ("idChoix", "idQuestion", "isCorrect", "nomChoix", "position") SELECT "idChoix", "idQuestion", "isCorrect", "nomChoix", "position" FROM "Choix"; -DROP TABLE "Choix"; -ALTER TABLE "new_Choix" RENAME TO "Choix"; -CREATE TABLE "new_Reponse" ( - "idReponse" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "idQuestion" INTEGER NOT NULL, - "idChoix" INTEGER, - "idUser" INTEGER NOT NULL, - "numeric" REAL, - CONSTRAINT "Reponse_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question" ("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Reponse_idChoix_fkey" FOREIGN KEY ("idChoix") REFERENCES "Choix" ("idChoix") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "Reponse_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Reponse" ("idChoix", "idQuestion", "idReponse", "idUser", "numeric") SELECT "idChoix", "idQuestion", "idReponse", "idUser", "numeric" FROM "Reponse"; -DROP TABLE "Reponse"; -ALTER TABLE "new_Reponse" RENAME TO "Reponse"; -CREATE UNIQUE INDEX "Reponse_idQuestion_idUser_idChoix_key" ON "Reponse"("idQuestion", "idUser", "idChoix"); -PRAGMA foreign_key_check("Choix"); -PRAGMA foreign_key_check("Reponse"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240613195132_database/migration.sql b/microservices/helloworld/prisma/migrations/20240613195132_database/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240613195132_database/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240615191543_/migration.sql b/microservices/helloworld/prisma/migrations/20240615191543_/migration.sql deleted file mode 100644 index 83a47a170d186acdff08f8a62732daca9101b38c..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240615191543_/migration.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* - Warnings: - - - Added the required column `score` to the `Participer` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - "score" INTEGER NOT NULL, - "heureDebut" INTEGER NOT NULL, - "hasFinished" BOOLEAN NOT NULL DEFAULT false, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "hasFinished", "heureDebut", "idQCM", "idUser", "note") SELECT "feedback", "hasFinished", "heureDebut", "idQCM", "idUser", "note" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240615192133_/migration.sql b/microservices/helloworld/prisma/migrations/20240615192133_/migration.sql deleted file mode 100644 index 9be8341dc8496f232a0d47197d53a2e9cee9a1ba..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240615192133_/migration.sql +++ /dev/null @@ -1,20 +0,0 @@ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - "score" INTEGER, - "heureDebut" INTEGER NOT NULL, - "hasFinished" BOOLEAN NOT NULL DEFAULT false, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "hasFinished", "heureDebut", "idQCM", "idUser", "note", "score") SELECT "feedback", "hasFinished", "heureDebut", "idQCM", "idUser", "note", "score" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240615194339_/migration.sql b/microservices/helloworld/prisma/migrations/20240615194339_/migration.sql deleted file mode 100644 index a1699f146a0ab8677b7898217e393da9462b81f5..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240615194339_/migration.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* - Warnings: - - - Made the column `score` on table `Participer` required. This step will fail if there are existing NULL values in that column. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Participer" ( - "idUser" INTEGER NOT NULL, - "idQCM" INTEGER NOT NULL, - "feedback" TEXT NOT NULL, - "note" REAL NOT NULL, - "score" INTEGER NOT NULL, - "heureDebut" INTEGER NOT NULL, - "hasFinished" BOOLEAN NOT NULL DEFAULT false, - - PRIMARY KEY ("idUser", "idQCM"), - CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Participer" ("feedback", "hasFinished", "heureDebut", "idQCM", "idUser", "note", "score") SELECT "feedback", "hasFinished", "heureDebut", "idQCM", "idUser", "note", "score" FROM "Participer"; -DROP TABLE "Participer"; -ALTER TABLE "new_Participer" RENAME TO "Participer"; -PRAGMA foreign_key_check("Participer"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240615194422_add_score/migration.sql b/microservices/helloworld/prisma/migrations/20240615194422_add_score/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240615194422_add_score/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240615195336_regle_erreur/migration.sql b/microservices/helloworld/prisma/migrations/20240615195336_regle_erreur/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240615195336_regle_erreur/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240615235649_add_random_order_choix/migration.sql b/microservices/helloworld/prisma/migrations/20240615235649_add_random_order_choix/migration.sql deleted file mode 100644 index 4e5fbeeaabab3ab0b1062ed02df8884c4893fe69..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240615235649_add_random_order_choix/migration.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* - Warnings: - - - Added the required column `randomOrder` to the `Question` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "randomOrder" BOOLEAN NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" INTEGER, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - "isMultiple" BOOLEAN NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Question" ("idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question") SELECT "idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question" FROM "Question"; -DROP TABLE "Question"; -ALTER TABLE "new_Question" RENAME TO "Question"; -PRAGMA foreign_key_check("Question"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20240615235741_addorder/migration.sql b/microservices/helloworld/prisma/migrations/20240615235741_addorder/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240615235741_addorder/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240616122454_/migration.sql b/microservices/helloworld/prisma/migrations/20240616122454_/migration.sql deleted file mode 100644 index e0ece44a633f8583f16222900e00656f9dbe4dcc..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240616122454_/migration.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* - Warnings: - - - You are about to alter the column `numeric` on the `Question` table. The data in that column could be lost. The data in that column will be cast from `Int` to `Float`. - -*/ --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" REAL, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - "isMultiple" BOOLEAN NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Question" ("idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question") SELECT "idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question" FROM "Question"; -DROP TABLE "Question"; -ALTER TABLE "new_Question" RENAME TO "Question"; -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; diff --git a/microservices/helloworld/prisma/migrations/20240616122525_change_type_numeric_question/migration.sql b/microservices/helloworld/prisma/migrations/20240616122525_change_type_numeric_question/migration.sql deleted file mode 100644 index af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240616122525_change_type_numeric_question/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/microservices/helloworld/prisma/migrations/20240616125927_new_mig/migration.sql b/microservices/helloworld/prisma/migrations/20240616125927_new_mig/migration.sql deleted file mode 100644 index d0391af090793df9c3cef54babd70e35e0c9ce6c..0000000000000000000000000000000000000000 --- a/microservices/helloworld/prisma/migrations/20240616125927_new_mig/migration.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* - Warnings: - - - Added the required column `randomOrder` to the `Question` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Question" ( - "idQuestion" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "question" TEXT NOT NULL, - "position" INTEGER NOT NULL, - "randomOrder" BOOLEAN NOT NULL, - "nbPtsPositif" INTEGER NOT NULL, - "nbPtsNegatif" INTEGER NOT NULL, - "numeric" REAL, - "idQCM" INTEGER NOT NULL, - "idType" INTEGER NOT NULL, - "isMultiple" BOOLEAN NOT NULL, - CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable" ("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type" ("idType") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_Question" ("idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question") SELECT "idQCM", "idQuestion", "idType", "isMultiple", "nbPtsNegatif", "nbPtsPositif", "numeric", "position", "question" FROM "Question"; -DROP TABLE "Question"; -ALTER TABLE "new_Question" RENAME TO "Question"; -PRAGMA foreign_key_check("Question"); -PRAGMA foreign_keys=ON; diff --git a/microservices/helloworld/prisma/migrations/20250316233505_init/migration.sql b/microservices/helloworld/prisma/migrations/20250316233505_init/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..14e94334a88ac4e92ce6ca7086f1d4f8fb181051 --- /dev/null +++ b/microservices/helloworld/prisma/migrations/20250316233505_init/migration.sql @@ -0,0 +1,120 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" INTEGER NOT NULL, + "name" TEXT, + "mail" TEXT, + "gitlabUsername" TEXT NOT NULL, + "deleted" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "QcmTable" ( + "idQCM" SERIAL NOT NULL, + "nomQCM" TEXT NOT NULL, + "temps" INTEGER NOT NULL, + "randomOrder" BOOLEAN NOT NULL, + "codeAcces" INTEGER NOT NULL, + "idUserCreator" INTEGER NOT NULL, + + CONSTRAINT "QcmTable_pkey" PRIMARY KEY ("idQCM") +); + +-- CreateTable +CREATE TABLE "Type" ( + "idType" SERIAL NOT NULL, + "nomType" TEXT NOT NULL, + + CONSTRAINT "Type_pkey" PRIMARY KEY ("idType") +); + +-- CreateTable +CREATE TABLE "Choix" ( + "idChoix" SERIAL NOT NULL, + "isCorrect" BOOLEAN NOT NULL, + "idQuestion" INTEGER NOT NULL, + "nomChoix" TEXT NOT NULL, + "position" INTEGER NOT NULL, + + CONSTRAINT "Choix_pkey" PRIMARY KEY ("idChoix") +); + +-- CreateTable +CREATE TABLE "Question" ( + "idQuestion" SERIAL NOT NULL, + "question" TEXT NOT NULL, + "position" INTEGER NOT NULL, + "randomOrder" BOOLEAN NOT NULL, + "nbPtsPositif" INTEGER NOT NULL, + "nbPtsNegatif" INTEGER NOT NULL, + "numeric" DOUBLE PRECISION, + "idQCM" INTEGER NOT NULL, + "idType" INTEGER NOT NULL, + "isMultiple" BOOLEAN NOT NULL, + + CONSTRAINT "Question_pkey" PRIMARY KEY ("idQuestion") +); + +-- CreateTable +CREATE TABLE "Reponse" ( + "idReponse" SERIAL NOT NULL, + "idQuestion" INTEGER NOT NULL, + "idChoix" INTEGER, + "idUser" INTEGER NOT NULL, + "numeric" DOUBLE PRECISION, + + CONSTRAINT "Reponse_pkey" PRIMARY KEY ("idReponse") +); + +-- CreateTable +CREATE TABLE "Participer" ( + "idUser" INTEGER NOT NULL, + "idQCM" INTEGER NOT NULL, + "feedback" TEXT NOT NULL, + "note" DOUBLE PRECISION NOT NULL, + "score" INTEGER NOT NULL, + "heureDebut" INTEGER NOT NULL, + "hasFinished" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "Participer_pkey" PRIMARY KEY ("idUser","idQCM") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_mail_key" ON "User"("mail"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_gitlabUsername_key" ON "User"("gitlabUsername"); + +-- CreateIndex +CREATE UNIQUE INDEX "Type_nomType_key" ON "Type"("nomType"); + +-- CreateIndex +CREATE UNIQUE INDEX "Reponse_idQuestion_idUser_idChoix_key" ON "Reponse"("idQuestion", "idUser", "idChoix"); + +-- AddForeignKey +ALTER TABLE "QcmTable" ADD CONSTRAINT "QcmTable_idUserCreator_fkey" FOREIGN KEY ("idUserCreator") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Choix" ADD CONSTRAINT "Choix_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question"("idQuestion") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Question" ADD CONSTRAINT "Question_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable"("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Question" ADD CONSTRAINT "Question_idType_fkey" FOREIGN KEY ("idType") REFERENCES "Type"("idType") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Reponse" ADD CONSTRAINT "Reponse_idQuestion_fkey" FOREIGN KEY ("idQuestion") REFERENCES "Question"("idQuestion") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Reponse" ADD CONSTRAINT "Reponse_idChoix_fkey" FOREIGN KEY ("idChoix") REFERENCES "Choix"("idChoix") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Reponse" ADD CONSTRAINT "Reponse_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Participer" ADD CONSTRAINT "Participer_idUser_fkey" FOREIGN KEY ("idUser") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Participer" ADD CONSTRAINT "Participer_idQCM_fkey" FOREIGN KEY ("idQCM") REFERENCES "QcmTable"("idQCM") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/microservices/helloworld/prisma/migrations/migration_lock.toml b/microservices/helloworld/prisma/migrations/migration_lock.toml index e5e5c4705ab084270b7de6f45d5291ba01666948..648c57fd59d83581e928372c012c2073cc0a1158 100644 --- a/microservices/helloworld/prisma/migrations/migration_lock.toml +++ b/microservices/helloworld/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file +# It should be added in your version-control system (e.g., Git) +provider = "postgresql" \ No newline at end of file diff --git a/microservices/helloworld/prisma/schema.prisma b/microservices/helloworld/prisma/schema.prisma index 8d1834cf087c732f9c70bc15db41d61621dc91a1..981df4b3dad6eb703bf195e690ecb52f9ffe056b 100644 --- a/microservices/helloworld/prisma/schema.prisma +++ b/microservices/helloworld/prisma/schema.prisma @@ -35,7 +35,7 @@ model QcmTable { model Type { idType Int @id @default(autoincrement()) - nomType String + nomType String @unique questions Question[] } diff --git a/microservices/helloworld/prisma/seed.ts b/microservices/helloworld/prisma/seed.ts index 7d08e7c3f6cb9eec34f9e9fdc890aec227f46d8d..37b26eda2c4857396998ea05d6d7f95a7eea9011 100644 --- a/microservices/helloworld/prisma/seed.ts +++ b/microservices/helloworld/prisma/seed.ts @@ -1,11 +1,11 @@ import process from 'process'; -import logger from '../src/logging/WinstonLogger.js'; -import db from '../src/helpers/DatabaseHelper.js'; -import Config from '../src/config/Config.js'; - +import logger from '../src/logging/WinstonLogger.js'; +import db from '../src/helpers/DatabaseHelper.js'; +import Config from '../src/config/Config.js'; async function main() { await users(); + await types(); } main().then(async () => { @@ -20,47 +20,57 @@ main().then(async () => { async function users() { await db.user.upsert({ - where : { id: 142 }, - update: { - name: 'Michaël Minelli' - }, - create: { - id : 142, - name : 'Michaël Minelli', - gitlabUsername: 'michael.minelli', - deleted : false - } - }); + where: { id: 142 }, + update: { + name: 'Michaël Minelli' + }, + create: { + id: 142, + name: 'Michaël Minelli', + gitlabUsername: 'michael.minelli', + deleted: false + } + }); - if ( !Config.production ) { + if (!Config.production) { await db.user.upsert({ - where : { id: 525 }, - update: { - deleted: false - }, - create: { - id : 525, - gitlabUsername: 'stephane.malandai', - deleted : false - } - }); + where: { id: 525 }, + update: { + deleted: false + }, + create: { + id: 525, + gitlabUsername: 'stephane.malandai', + deleted: false + } + }); } - await db.type.create({ - data: { - idType : 1, - nomType : 'text', +} + +async function types() { + await db.type.upsert({ + where: { nomType: 'text' }, + update: {}, + create: { + nomType: 'text' } }); - await db.type.create({ - data: { - idType : 2, - nomType : 'numerique', + + await db.type.upsert({ + where: { nomType: 'numerique' }, + update: {}, + create: { + nomType: 'numerique' } }); - await db.type.create({ - data: { - idType : 3, - nomType : 'vraiFaux', + + await db.type.upsert({ + where: { nomType: 'vraiFaux' }, + update: {}, + create: { + nomType: 'vraiFaux' } }); -} \ No newline at end of file + + console.log("✅ Types de base insérés ou déjà présents."); +}