This commit is contained in:
Fred 2025-04-16 13:50:38 +02:00
parent 04e0200d8b
commit d7870a8153
8 changed files with 273 additions and 3 deletions

2
.env
View File

@ -4,4 +4,4 @@
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="mysql://<username>:<password>@<url_bdd>:<port_bdd>/<nom_bdd>?schema=public" DATABASE_URL="mysql://monelia:monelia@localhost:3306/monelia?schema=public"

2
.gitignore vendored
View File

@ -31,7 +31,7 @@ yarn-error.log*
.pnpm-debug.log* .pnpm-debug.log*
# env files (can opt-in for committing if needed) # env files (can opt-in for committing if needed)
#.env* .env*
# vercel # vercel
.vercel .vercel

23
package-lock.json generated
View File

@ -8,6 +8,7 @@
"name": "monelia-nails", "name": "monelia-nails",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@prisma/client": "^6.6.0",
"next": "15.3.0", "next": "15.3.0",
"prisma": "^6.6.0", "prisma": "^6.6.0",
"react": "^19.0.0", "react": "^19.0.0",
@ -1270,6 +1271,28 @@
"node": ">=12.4.0" "node": ">=12.4.0"
} }
}, },
"node_modules/@prisma/client": {
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.6.0.tgz",
"integrity": "sha512-vfp73YT/BHsWWOAuthKQ/1lBgESSqYqAWZEYyTdGXyFAHpmewwWL2Iz6ErIzkj4aHbuc6/cGSsE6ZY+pBO04Cg==",
"hasInstallScript": true,
"license": "Apache-2.0",
"engines": {
"node": ">=18.18"
},
"peerDependencies": {
"prisma": "*",
"typescript": ">=5.1.0"
},
"peerDependenciesMeta": {
"prisma": {
"optional": true
},
"typescript": {
"optional": true
}
}
},
"node_modules/@prisma/config": { "node_modules/@prisma/config": {
"version": "6.6.0", "version": "6.6.0",
"resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.6.0.tgz", "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.6.0.tgz",

View File

@ -9,6 +9,7 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@prisma/client": "^6.6.0",
"next": "15.3.0", "next": "15.3.0",
"prisma": "^6.6.0", "prisma": "^6.6.0",
"react": "^19.0.0", "react": "^19.0.0",

View File

@ -0,0 +1,130 @@
-- CreateTable
CREATE TABLE `Utilisateur` (
`ut_id` INTEGER NOT NULL AUTO_INCREMENT,
`ut_nom` VARCHAR(191) NULL,
`ut_prenom` VARCHAR(191) NULL,
`ut_mail` VARCHAR(191) NULL,
`ut_type_cliente` INTEGER NULL,
`ut_age` DATETIME(3) NULL,
`ut_nb_rdv` INTEGER NULL,
`ut_nb_rdv_honores` INTEGER NULL,
`ut_prix_moyen` INTEGER NULL,
`ut_pdp` INTEGER NULL,
`ut_panier` INTEGER NULL,
`ut_mdp` INTEGER NULL,
`ut_telephone` INTEGER NULL,
`ut_date_inscription` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`ut_derniere_connexion` DATETIME(3) NULL,
`ut_slug` VARCHAR(191) NULL,
PRIMARY KEY (`ut_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Formation` (
`fo_id` INTEGER NOT NULL AUTO_INCREMENT,
`fo_titre` VARCHAR(191) NULL,
`fo_description` VARCHAR(191) NULL,
`fo_prix` VARCHAR(191) NULL,
`fo_miniature` LONGBLOB NULL,
`fo_teaser` VARCHAR(191) NULL,
`fo_date_publication` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`fo_desactive` BOOLEAN NOT NULL DEFAULT false,
`fo_slug` VARCHAR(191) NULL,
PRIMARY KEY (`fo_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Video` (
`vi_fo_id` INTEGER NOT NULL,
`vi_id` INTEGER NOT NULL AUTO_INCREMENT,
`vi_titre` VARCHAR(191) NULL,
`vi_description` VARCHAR(191) NULL,
`vi_etape` INTEGER NULL,
`vi_url` VARCHAR(191) NULL,
`vi_slug` VARCHAR(191) NULL,
PRIMARY KEY (`vi_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Commande` (
`co_id` INTEGER NOT NULL AUTO_INCREMENT,
`co_utilisateur` INTEGER NOT NULL,
`co_date_creation` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`co_date_update` DATETIME(3) NULL,
`co_slug` VARCHAR(191) NULL,
`co_status` VARCHAR(191) NOT NULL DEFAULT 'IN PROGRESS',
PRIMARY KEY (`co_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `CommandeFormation` (
`cof_id` INTEGER NOT NULL AUTO_INCREMENT,
`cof_formation` INTEGER NOT NULL,
`cof_slug` VARCHAR(191) NULL,
PRIMARY KEY (`cof_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Achat` (
`ac_id` INTEGER NOT NULL AUTO_INCREMENT,
`ac_utilisateur` INTEGER NOT NULL,
`ac_formation` INTEGER NOT NULL,
`ac_type` VARCHAR(191) NULL,
`ac_slug` VARCHAR(191) NULL,
`ac_date_achat` DATETIME(3) NULL,
`ac_date_fin` DATETIME(3) NULL,
PRIMARY KEY (`ac_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Tag` (
`ta_id` INTEGER NOT NULL AUTO_INCREMENT,
`ta_titre` VARCHAR(191) NULL,
`ta_slug` VARCHAR(191) NULL,
PRIMARY KEY (`ta_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `TagVideo` (
`tv_tag_id` INTEGER NOT NULL,
`tv_video_id` INTEGER NOT NULL,
PRIMARY KEY (`tv_tag_id`, `tv_video_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Session` (
`ut_id` INTEGER NOT NULL,
`createAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`expireAt` DATETIME(3) NULL,
PRIMARY KEY (`ut_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `Video` ADD CONSTRAINT `Video_vi_fo_id_fkey` FOREIGN KEY (`vi_fo_id`) REFERENCES `Formation`(`fo_id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Commande` ADD CONSTRAINT `Commande_co_utilisateur_fkey` FOREIGN KEY (`co_utilisateur`) REFERENCES `Utilisateur`(`ut_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `CommandeFormation` ADD CONSTRAINT `CommandeFormation_cof_formation_fkey` FOREIGN KEY (`cof_formation`) REFERENCES `Formation`(`fo_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Achat` ADD CONSTRAINT `Achat_ac_utilisateur_fkey` FOREIGN KEY (`ac_utilisateur`) REFERENCES `Utilisateur`(`ut_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Achat` ADD CONSTRAINT `Achat_ac_formation_fkey` FOREIGN KEY (`ac_formation`) REFERENCES `Formation`(`fo_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `TagVideo` ADD CONSTRAINT `TagVideo_tv_tag_id_fkey` FOREIGN KEY (`tv_tag_id`) REFERENCES `Tag`(`ta_id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `TagVideo` ADD CONSTRAINT `TagVideo_tv_video_id_fkey` FOREIGN KEY (`tv_video_id`) REFERENCES `Video`(`vi_id`) ON DELETE CASCADE ON UPDATE CASCADE;

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 = "mysql"

View File

@ -6,10 +6,107 @@
generator client { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
output = "../src/generated/prisma"
} }
datasource db { datasource db {
provider = "mysql" provider = "mysql"
url = env("DATABASE_URL") url = env("DATABASE_URL")
} }
model Utilisateur {
ut_id Int @id @default(autoincrement())
ut_nom String?
ut_prenom String?
ut_mail String?
ut_type_cliente Int?
ut_age DateTime?
ut_nb_rdv Int?
ut_nb_rdv_honores Int?
ut_prix_moyen Int?
ut_pdp Int?
ut_panier Int?
ut_mdp Int?
ut_telephone Int?
ut_date_inscription DateTime @default(now())
ut_derniere_connexion DateTime?
ut_slug String?
commande Commande[]
achat Achat[]
}
model Formation {
fo_id Int @id @default(autoincrement())
fo_titre String?
fo_description String?
fo_prix String?
fo_miniature Bytes?
fo_teaser String?
fo_date_publication DateTime @default(now())
fo_desactive Boolean @default(false)
fo_slug String?
fo_video Video[]
commandeFormation CommandeFormation[]
achat Achat[]
}
model Video{
formation Formation @relation(fields: [vi_fo_id],references: [fo_id], onDelete: Cascade)
vi_fo_id Int
vi_id Int @id @default(autoincrement())
vi_titre String?
vi_description String?
vi_etape Int?
vi_url String?
vi_slug String?
vi_tv TagVideo[]
}
model Commande{
co_id Int @id @default(autoincrement())
co_utilisateur Int
utilisateur Utilisateur @relation(fields: [co_utilisateur],references: [ut_id])
co_date_creation DateTime @default(now())
co_date_update DateTime?
co_slug String?
co_status String @default("IN PROGRESS")
}
model CommandeFormation{
cof_id Int @id @default(autoincrement())
cof_formation Int
cof_slug String?
formation Formation @relation(fields: [cof_formation],references: [fo_id])
}
model Achat{
ac_id Int @id @default(autoincrement())
ac_utilisateur Int
utilisateur Utilisateur @relation(fields: [ac_utilisateur],references: [ut_id])
ac_formation Int
formation Formation @relation(fields: [ac_formation],references: [fo_id])
ac_type String?
ac_slug String ?
ac_date_achat DateTime?
ac_date_fin DateTime?
}
model Tag {
ta_id Int @id @default(autoincrement())
ta_titre String?
ta_slug String?
vi_tv TagVideo[]
}
model TagVideo{
@@id([tv_tag_id, tv_video_id])
tv_tag_id Int
tag Tag @relation(fields: [tv_tag_id],references: [ta_id], onDelete: Cascade)
tv_video_id Int
video Video @relation(fields: [tv_video_id],references: [vi_id], onDelete: Cascade)
}
model Session{
ut_id Int @id
createAt DateTime @default(now())
expireAt DateTime?
}

16
src/lib/db.ts Normal file
View File

@ -0,0 +1,16 @@
import { PrismaClient } from "@prisma/client"
const prismaClientSingleton = () => {
return new PrismaClient()
}
declare const globalThis:{
prismaGlobal : ReturnType<typeof prismaClientSingleton>
} & typeof global
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
export default prisma
if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;