mirror of
https://github.com/Floriansylvain/ParisMuseesQuizz.git
synced 2026-08-19 11:43:22 +02:00
Added DB schemas and prisma migration
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `User` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`email` VARCHAR(191) NOT NULL,
|
||||
`password` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `User_email_key`(`email`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Author` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`fullname` VARCHAR(191) NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Painting` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`image_url` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `PaintingAuthor` (
|
||||
`painting_id` INTEGER NOT NULL,
|
||||
`author_id` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`painting_id`, `author_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `PaintingAuthor` ADD CONSTRAINT `PaintingAuthor_painting_id_fkey` FOREIGN KEY (`painting_id`) REFERENCES `Painting`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `PaintingAuthor` ADD CONSTRAINT `PaintingAuthor_author_id_fkey` FOREIGN KEY (`author_id`) REFERENCES `Author`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "mysql"
|
||||
@@ -15,3 +15,27 @@ model User {
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Author {
|
||||
id Int @id @default(autoincrement())
|
||||
fullname String
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
PaintingAuthor PaintingAuthor[]
|
||||
}
|
||||
|
||||
model Painting {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
image_url String
|
||||
PaintingAuthor PaintingAuthor[]
|
||||
}
|
||||
|
||||
model PaintingAuthor {
|
||||
painting Painting @relation(fields: [painting_id], references: [id])
|
||||
painting_id Int
|
||||
author Author @relation(fields: [author_id], references: [id])
|
||||
author_id Int
|
||||
|
||||
@@id([painting_id, author_id])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user