Skip to content
Snippets Groups Projects
Commit bacf273f authored by Abelangel's avatar Abelangel
Browse files

probleme de creation des questions resolue

parent e647177e
Branches
No related tags found
No related merge requests found
Showing
with 161 additions and 559 deletions
......@@ -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 });
}
});
......
......@@ -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"]
#!/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
File deleted
-- This is an empty migration.
\ No newline at end of file
-- 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");
-- 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
);
/*
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;
/*
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;
/*
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;
/*
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;
/*
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;
/*
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;
/*
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;
-- This is an empty migration.
\ No newline at end of file
/*
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;
/*
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;
-- 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;
/*
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;
-- This is an empty migration.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment