database: setup of prisma
This commit is contained in:
46
prisma/migrations/20240317161445_init/migration.sql
Normal file
46
prisma/migrations/20240317161445_init/migration.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `GameSystem` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`created` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Schema` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`gameSystemId` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`schema` JSON NOT NULL,
|
||||
`version` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Publication` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`schemaId` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`data` JSON NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Tag` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`publicationId` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Schema` ADD CONSTRAINT `Schema_gameSystemId_fkey` FOREIGN KEY (`gameSystemId`) REFERENCES `GameSystem`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Publication` ADD CONSTRAINT `Publication_schemaId_fkey` FOREIGN KEY (`schemaId`) REFERENCES `Schema`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Tag` ADD CONSTRAINT `Tag_publicationId_fkey` FOREIGN KEY (`publicationId`) REFERENCES `Publication`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
8
prisma/migrations/20240317164602_update/migration.sql
Normal file
8
prisma/migrations/20240317164602_update/migration.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[name]` on the table `GameSystem` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `GameSystem_name_key` ON `GameSystem`(`name`);
|
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@@ -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"
|
49
prisma/schema.prisma
Normal file
49
prisma/schema.prisma
Normal file
@@ -0,0 +1,49 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model GameSystem {
|
||||
id String @id @default(cuid())
|
||||
schemas Schema[]
|
||||
|
||||
name String @unique
|
||||
created DateTime @default(now())
|
||||
}
|
||||
|
||||
model Schema {
|
||||
id String @id @default(cuid())
|
||||
gameSystem GameSystem @relation(fields: [gameSystemId], references: [id])
|
||||
gameSystemId String
|
||||
publications Publication[]
|
||||
|
||||
name String
|
||||
schema Json
|
||||
version Int
|
||||
}
|
||||
|
||||
model Publication {
|
||||
id String @id @default(cuid())
|
||||
schema Schema @relation(fields: [schemaId], references: [id])
|
||||
schemaId String
|
||||
tags Tag[]
|
||||
|
||||
name String
|
||||
data Json
|
||||
}
|
||||
|
||||
model Tag {
|
||||
id String @id @default(cuid())
|
||||
publication Publication @relation(fields: [publicationId], references: [id])
|
||||
publicationId String
|
||||
}
|
Reference in New Issue
Block a user