new tags, migration
This commit is contained in:
parent
0f100bba3d
commit
9e2184352f
83
prisma/migrations/20240815100640_retagging/migration.sql
Normal file
83
prisma/migrations/20240815100640_retagging/migration.sql
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- Added the required column `authorId` to the `GameSystem` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `authorId` to the `Publication` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `authorId` to the `Schema` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `originalId` to the `Schema` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `name` to the `Tag` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE `Schema` DROP FOREIGN KEY `Schema_gameSystemId_fkey`;
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE `Tag` DROP FOREIGN KEY `Tag_publicationId_fkey`;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE `GameSystem` ADD COLUMN `authorId` VARCHAR(191) NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE `Publication` ADD COLUMN `authorId` VARCHAR(191) NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE `Schema` ADD COLUMN `authorId` VARCHAR(191) NOT NULL,
|
||||||
|
ADD COLUMN `originalId` VARCHAR(191) NOT NULL,
|
||||||
|
MODIFY `gameSystemId` VARCHAR(191) NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE `Tag` ADD COLUMN `name` VARCHAR(191) NOT NULL,
|
||||||
|
MODIFY `publicationId` VARCHAR(191) NULL;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `TagsOnPublications` (
|
||||||
|
`publicationId` VARCHAR(191) NOT NULL,
|
||||||
|
`tagId` VARCHAR(191) NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (`publicationId`, `tagId`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `TagsOnTags` (
|
||||||
|
`parentTagId` VARCHAR(191) NOT NULL,
|
||||||
|
`childTagId` VARCHAR(191) NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (`parentTagId`, `childTagId`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `User` (
|
||||||
|
`id` VARCHAR(191) NOT NULL,
|
||||||
|
`username` VARCHAR(191) NOT NULL,
|
||||||
|
`email` VARCHAR(191) NOT NULL,
|
||||||
|
|
||||||
|
UNIQUE INDEX `User_email_key`(`email`),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `GameSystem` ADD CONSTRAINT `GameSystem_authorId_fkey` FOREIGN KEY (`authorId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `Schema` ADD CONSTRAINT `Schema_gameSystemId_fkey` FOREIGN KEY (`gameSystemId`) REFERENCES `GameSystem`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `Schema` ADD CONSTRAINT `Schema_authorId_fkey` FOREIGN KEY (`authorId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `Publication` ADD CONSTRAINT `Publication_authorId_fkey` FOREIGN KEY (`authorId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `TagsOnPublications` ADD CONSTRAINT `TagsOnPublications_publicationId_fkey` FOREIGN KEY (`publicationId`) REFERENCES `Publication`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `TagsOnPublications` ADD CONSTRAINT `TagsOnPublications_tagId_fkey` FOREIGN KEY (`tagId`) REFERENCES `Tag`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `Tag` ADD CONSTRAINT `Tag_publicationId_fkey` FOREIGN KEY (`publicationId`) REFERENCES `Publication`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `TagsOnTags` ADD CONSTRAINT `TagsOnTags_parentTagId_fkey` FOREIGN KEY (`parentTagId`) REFERENCES `Tag`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `TagsOnTags` ADD CONSTRAINT `TagsOnTags_childTagId_fkey` FOREIGN KEY (`childTagId`) REFERENCES `Tag`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -25,8 +25,8 @@ model GameSystem {
|
|||||||
|
|
||||||
model Schema {
|
model Schema {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
gameSystem GameSystem @relation(fields: [gameSystemId], references: [id])
|
gameSystem GameSystem? @relation(fields: [gameSystemId], references: [id])
|
||||||
gameSystemId String
|
gameSystemId String?
|
||||||
publications Publication[]
|
publications Publication[]
|
||||||
author User @relation(fields: [authorId], references: [id])
|
author User @relation(fields: [authorId], references: [id])
|
||||||
authorId String
|
authorId String
|
||||||
@ -48,12 +48,35 @@ model Publication {
|
|||||||
|
|
||||||
name String
|
name String
|
||||||
data Json
|
data Json
|
||||||
|
TagsOnPublications TagsOnPublications[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model TagsOnPublications {
|
||||||
|
publication Publication @relation(fields: [publicationId], references: [id])
|
||||||
|
publicationId String
|
||||||
|
tagId String
|
||||||
|
tag Tag @relation(fields: [tagId], references: [id])
|
||||||
|
|
||||||
|
@@id([publicationId, tagId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Tag {
|
model Tag {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
publication Publication @relation(fields: [publicationId], references: [id])
|
name String
|
||||||
publicationId String
|
Publication Publication? @relation(fields: [publicationId], references: [id])
|
||||||
|
publicationId String?
|
||||||
|
TagsOnPublications TagsOnPublications[]
|
||||||
|
childTagsOnTags TagsOnTags[] @relation("childTag")
|
||||||
|
parentTagsOnTags TagsOnTags[] @relation("parentTag")
|
||||||
|
}
|
||||||
|
|
||||||
|
model TagsOnTags {
|
||||||
|
parentTagId String
|
||||||
|
parentTag Tag @relation(fields: [parentTagId], references: [id], "parentTag")
|
||||||
|
childTagId String
|
||||||
|
childTag Tag @relation(fields: [childTagId], references: [id], "childTag")
|
||||||
|
|
||||||
|
@@id([parentTagId, childTagId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user