mirror of
https://github.com/Floriansylvain/ParisMuseesQuizz.git
synced 2026-08-19 11:43:22 +02:00
Updated Models
This commit is contained in:
+18
@@ -18,6 +18,7 @@ CREATE TABLE `Author` (
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `Author_fullname_key`(`fullname`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -26,7 +27,10 @@ CREATE TABLE `Painting` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`image_url` VARCHAR(191) NOT NULL,
|
||||
`link` VARCHAR(191) NOT NULL,
|
||||
`musuemId` INTEGER NULL,
|
||||
|
||||
UNIQUE INDEX `Painting_name_key`(`name`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -38,6 +42,20 @@ CREATE TABLE `PaintingAuthor` (
|
||||
PRIMARY KEY (`painting_id`, `author_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Musuem` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `Musuem_name_key`(`name`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Painting` ADD CONSTRAINT `Painting_musuemId_fkey` FOREIGN KEY (`musuemId`) REFERENCES `Musuem`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `PaintingAuthor` ADD CONSTRAINT `PaintingAuthor_painting_id_fkey` FOREIGN KEY (`painting_id`) REFERENCES `Painting`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
+13
-2
@@ -18,7 +18,7 @@ model User {
|
||||
|
||||
model Author {
|
||||
id Int @id @default(autoincrement())
|
||||
fullname String
|
||||
fullname String @unique
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
PaintingAuthor PaintingAuthor[]
|
||||
@@ -26,9 +26,12 @@ model Author {
|
||||
|
||||
model Painting {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
name String @unique
|
||||
image_url String
|
||||
link String
|
||||
PaintingAuthor PaintingAuthor[]
|
||||
Musuem Musuem? @relation(fields: [musuemId], references: [id])
|
||||
musuemId Int?
|
||||
}
|
||||
|
||||
model PaintingAuthor {
|
||||
@@ -39,3 +42,11 @@ model PaintingAuthor {
|
||||
|
||||
@@id([painting_id, author_id])
|
||||
}
|
||||
|
||||
model Musuem {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
Painting Painting[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user