chore: update project configuration by adding Prisma dependencies, generating Prisma client, and updating .gitignore; remove package-lock.json

This commit is contained in:
Julien Froidefond
2025-11-27 13:01:38 +01:00
parent 6d95529579
commit 68ef3731fa
11 changed files with 849 additions and 6597 deletions

2
.gitignore vendored
View File

@@ -39,3 +39,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
/src/generated/prisma

BIN
dev.db Normal file

Binary file not shown.

View File

@@ -45,8 +45,8 @@ Application de gestion d'ateliers SWOT pour entretiens managériaux.
## Phase 2 : Base de Données
- [ ] Installer et configurer Prisma
- [ ] Créer le schéma de base de données :
- [x] Installer et configurer Prisma
- [x] Créer le schéma de base de données :
```prisma
model User {
id String @id @default(cuid())
@@ -114,9 +114,9 @@ Application de gestion d'ateliers SWOT pour entretiens managériaux.
@@unique([actionId, swotItemId])
}
```
- [ ] Générer le client Prisma
- [ ] Créer les migrations initiales
- [ ] Créer le service database.ts (pool de connexion)
- [x] Générer le client Prisma
- [x] Créer les migrations initiales
- [x] Créer le service database.ts (pool de connexion)
---

6592
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,9 @@
"name": "swot-manager",
"version": "0.1.0",
"private": true,
"pnpm": {
"onlyBuiltDependencies": ["prisma", "@prisma/engines"]
},
"scripts": {
"dev": "next dev",
"build": "next build",
@@ -9,7 +12,9 @@
"lint": "eslint"
},
"dependencies": {
"@prisma/client": "^7.0.1",
"next": "16.0.5",
"prisma": "^7.0.1",
"react": "19.2.0",
"react-dom": "19.2.0"
},
@@ -18,6 +23,7 @@
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"dotenv": "^17.2.3",
"eslint": "^9",
"eslint-config-next": "16.0.5",
"eslint-config-prettier": "^10.1.8",

640
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

14
prisma.config.ts Normal file
View File

@@ -0,0 +1,14 @@
// This file was generated by Prisma and assumes you have installed the following:
// npm install --save-dev prisma dotenv
import "dotenv/config";
import { defineConfig, env } from "prisma/config";
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
},
datasource: {
url: env("DATABASE_URL"),
},
});

View File

@@ -0,0 +1,77 @@
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL PRIMARY KEY,
"email" TEXT NOT NULL,
"name" TEXT,
"password" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- CreateTable
CREATE TABLE "Session" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"collaborator" TEXT NOT NULL,
"date" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "SwotItem" (
"id" TEXT NOT NULL PRIMARY KEY,
"content" TEXT NOT NULL,
"category" TEXT NOT NULL,
"order" INTEGER NOT NULL DEFAULT 0,
"sessionId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "SwotItem_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "Session" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "Action" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"description" TEXT,
"priority" INTEGER NOT NULL DEFAULT 0,
"status" TEXT NOT NULL DEFAULT 'todo',
"dueDate" DATETIME,
"sessionId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Action_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "Session" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "ActionLink" (
"id" TEXT NOT NULL PRIMARY KEY,
"actionId" TEXT NOT NULL,
"swotItemId" TEXT NOT NULL,
CONSTRAINT "ActionLink_actionId_fkey" FOREIGN KEY ("actionId") REFERENCES "Action" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "ActionLink_swotItemId_fkey" FOREIGN KEY ("swotItemId") REFERENCES "SwotItem" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- CreateIndex
CREATE INDEX "Session_userId_idx" ON "Session"("userId");
-- CreateIndex
CREATE INDEX "SwotItem_sessionId_idx" ON "SwotItem"("sessionId");
-- CreateIndex
CREATE INDEX "Action_sessionId_idx" ON "Action"("sessionId");
-- CreateIndex
CREATE INDEX "ActionLink_actionId_idx" ON "ActionLink"("actionId");
-- CreateIndex
CREATE INDEX "ActionLink_swotItemId_idx" ON "ActionLink"("swotItemId");
-- CreateIndex
CREATE UNIQUE INDEX "ActionLink_actionId_swotItemId_key" ON "ActionLink"("actionId", "swotItemId");

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "sqlite"

84
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,84 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
}
model User {
id String @id @default(cuid())
email String @unique
name String?
password String
sessions Session[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Session {
id String @id @default(cuid())
title String
collaborator String
date DateTime @default(now())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
items SwotItem[]
actions Action[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
}
enum SwotCategory {
STRENGTH
WEAKNESS
OPPORTUNITY
THREAT
}
model SwotItem {
id String @id @default(cuid())
content String
category SwotCategory
order Int @default(0)
sessionId String
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
actionLinks ActionLink[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([sessionId])
}
model Action {
id String @id @default(cuid())
title String
description String?
priority Int @default(0)
status String @default("todo")
dueDate DateTime?
sessionId String
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
links ActionLink[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([sessionId])
}
model ActionLink {
id String @id @default(cuid())
actionId String
action Action @relation(fields: [actionId], references: [id], onDelete: Cascade)
swotItemId String
swotItem SwotItem @relation(fields: [swotItemId], references: [id], onDelete: Cascade)
@@unique([actionId, swotItemId])
@@index([actionId])
@@index([swotItemId])
}

18
src/services/database.ts Normal file
View File

@@ -0,0 +1,18 @@
import { PrismaClient } from '@prisma/client';
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
});
if (process.env.NODE_ENV !== 'production') {
globalForPrisma.prisma = prisma;
}
export default prisma;