new models
This commit is contained in:
parent
5b16cc60f7
commit
f87a759048
123
prisma/migrations/20240904083737_new_defaults/migration.sql
Normal file
123
prisma/migrations/20240904083737_new_defaults/migration.sql
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the column `authorId` on the `Publication` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the column `data` on the `Publication` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the column `originalId` on the `Schema` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the column `schema` on the `Schema` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the column `types` on the `Schema` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the column `version` on the `Schema` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the `TagsOnPublications` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `TagsOnTags` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- Added the required column `schemaVersion` to the `Publication` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `publicationRevisionId` to the `Tag` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Made the column `publicationId` on table `Tag` required. This step will fail if there are existing NULL values in that column.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "Publication" DROP CONSTRAINT "Publication_authorId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "Tag" DROP CONSTRAINT "Tag_publicationId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "TagsOnPublications" DROP CONSTRAINT "TagsOnPublications_publicationId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "TagsOnPublications" DROP CONSTRAINT "TagsOnPublications_tagId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "TagsOnTags" DROP CONSTRAINT "TagsOnTags_childTagId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "TagsOnTags" DROP CONSTRAINT "TagsOnTags_parentTagId_fkey";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "GameSystem" ADD COLUMN "isPublic" BOOLEAN NOT NULL DEFAULT false;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Publication" DROP COLUMN "authorId",
|
||||||
|
DROP COLUMN "data",
|
||||||
|
ADD COLUMN "schemaVersion" INTEGER NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Schema" DROP COLUMN "originalId",
|
||||||
|
DROP COLUMN "schema",
|
||||||
|
DROP COLUMN "types",
|
||||||
|
DROP COLUMN "version";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Tag" ADD COLUMN "publicationRevisionId" TEXT NOT NULL,
|
||||||
|
ALTER COLUMN "publicationId" SET NOT NULL;
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "TagsOnPublications";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "TagsOnTags";
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "SchemaRevision" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"schemaId" TEXT NOT NULL,
|
||||||
|
"fields" JSONB NOT NULL DEFAULT '{}',
|
||||||
|
"types" JSONB NOT NULL DEFAULT '{}',
|
||||||
|
"version" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"isFinal" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
|
||||||
|
CONSTRAINT "SchemaRevision_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "PublicationRevision" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"previousId" TEXT,
|
||||||
|
"publicationId" TEXT NOT NULL,
|
||||||
|
"authorId" TEXT NOT NULL,
|
||||||
|
"version" TEXT NOT NULL,
|
||||||
|
"isFinal" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"data" JSONB NOT NULL DEFAULT '{}',
|
||||||
|
|
||||||
|
CONSTRAINT "PublicationRevision_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "GameSystemFollows" (
|
||||||
|
"gameSystemId" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "GameSystemFollows_pkey" PRIMARY KEY ("userId","gameSystemId")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "SchemaRevision_schemaId_version_key" ON "SchemaRevision"("schemaId", "version");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "PublicationRevision_publicationId_version_key" ON "PublicationRevision"("publicationId", "version");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "SchemaRevision" ADD CONSTRAINT "SchemaRevision_schemaId_fkey" FOREIGN KEY ("schemaId") REFERENCES "Schema"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Publication" ADD CONSTRAINT "Publication_schemaVersion_schemaId_fkey" FOREIGN KEY ("schemaVersion", "schemaId") REFERENCES "SchemaRevision"("version", "schemaId") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "PublicationRevision" ADD CONSTRAINT "PublicationRevision_publicationId_fkey" FOREIGN KEY ("publicationId") REFERENCES "Publication"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "PublicationRevision" ADD CONSTRAINT "PublicationRevision_previousId_fkey" FOREIGN KEY ("previousId") REFERENCES "PublicationRevision"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "PublicationRevision" ADD CONSTRAINT "PublicationRevision_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("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;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Tag" ADD CONSTRAINT "Tag_publicationRevisionId_fkey" FOREIGN KEY ("publicationRevisionId") REFERENCES "PublicationRevision"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "GameSystemFollows" ADD CONSTRAINT "GameSystemFollows_gameSystemId_fkey" FOREIGN KEY ("gameSystemId") REFERENCES "GameSystem"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "GameSystemFollows" ADD CONSTRAINT "GameSystemFollows_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -12,9 +12,11 @@ model GameSystem {
|
|||||||
schemas Schema[]
|
schemas Schema[]
|
||||||
author User @relation(fields: [authorId], references: [id])
|
author User @relation(fields: [authorId], references: [id])
|
||||||
authorId String
|
authorId String
|
||||||
|
followers GameSystemFollows[]
|
||||||
|
|
||||||
name String @unique
|
name String @unique
|
||||||
created DateTime @default(now())
|
created DateTime @default(now())
|
||||||
|
isPublic Boolean @default(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
model Schema {
|
model Schema {
|
||||||
@ -34,12 +36,13 @@ model SchemaRevision {
|
|||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
schemaId String
|
schemaId String
|
||||||
parentSchema Schema @relation(fields: [schemaId], references: [id])
|
parentSchema Schema @relation(fields: [schemaId], references: [id])
|
||||||
|
|
||||||
schema Json
|
|
||||||
types Json
|
|
||||||
version Int
|
|
||||||
Publication Publication[]
|
Publication Publication[]
|
||||||
|
|
||||||
|
fields Json @default("{}")
|
||||||
|
types Json @default("{}")
|
||||||
|
version Int @default(0)
|
||||||
|
isFinal Boolean @default(false)
|
||||||
|
|
||||||
@@unique([schemaId, version])
|
@@unique([schemaId, version])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,20 +52,17 @@ model Publication {
|
|||||||
schemaId String
|
schemaId String
|
||||||
schemaVersion Int
|
schemaVersion Int
|
||||||
schemaRevision SchemaRevision @relation(fields: [schemaVersion, schemaId], references: [version, schemaId])
|
schemaRevision SchemaRevision @relation(fields: [schemaVersion, schemaId], references: [version, schemaId])
|
||||||
|
PublicationRevision PublicationRevision[]
|
||||||
tags Tag[]
|
tags Tag[]
|
||||||
|
|
||||||
name String
|
name String
|
||||||
|
|
||||||
TagsOnPublications TagsOnPublications[]
|
// TagsOnPublications TagsOnPublications[]
|
||||||
PublicationRevision PublicationRevision[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model PublicationRevision {
|
model PublicationRevision {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
version String
|
Tag Tag[]
|
||||||
isFinal Boolean
|
|
||||||
data Json
|
|
||||||
|
|
||||||
previousId String?
|
previousId String?
|
||||||
publicationId String
|
publicationId String
|
||||||
publication Publication @relation(fields: [publicationId], references: [id])
|
publication Publication @relation(fields: [publicationId], references: [id])
|
||||||
@ -71,41 +71,41 @@ model PublicationRevision {
|
|||||||
author User @relation(fields: [authorId], references: [id])
|
author User @relation(fields: [authorId], references: [id])
|
||||||
authorId String
|
authorId String
|
||||||
|
|
||||||
|
version String
|
||||||
|
isFinal Boolean @default(false)
|
||||||
|
data Json @default("{}")
|
||||||
|
|
||||||
@@unique([publicationId, version])
|
@@unique([publicationId, version])
|
||||||
}
|
}
|
||||||
|
|
||||||
model TagsOnPublications {
|
// model TagsOnPublications {
|
||||||
publication Publication @relation(fields: [publicationId], references: [id])
|
// publication Publication @relation(fields: [publicationId], references: [id])
|
||||||
publicationId String
|
// publicationId String
|
||||||
tagId String
|
// tagId String
|
||||||
tag Tag @relation(fields: [tagId], references: [id])
|
// tag Tag @relation(fields: [tagId], references: [id])
|
||||||
|
|
||||||
@@id([publicationId, tagId])
|
// @@id([publicationId, tagId])
|
||||||
}
|
// }
|
||||||
|
|
||||||
model Tag {
|
model Tag {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
name String
|
name String
|
||||||
Publication Publication? @relation(fields: [publicationId], references: [id])
|
Publication Publication @relation(fields: [publicationId], references: [id])
|
||||||
publicationId String?
|
publicationId String
|
||||||
TagsOnPublications TagsOnPublications[]
|
PublicationRevision PublicationRevision @relation(fields: [publicationRevisionId], references: [id])
|
||||||
childTagsOnTags TagsOnTags[] @relation("childTag")
|
publicationRevisionId String
|
||||||
parentTagsOnTags TagsOnTags[] @relation("parentTag")
|
|
||||||
}
|
|
||||||
|
|
||||||
model TagsOnTags {
|
// TagsOnPublications TagsOnPublications[]
|
||||||
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 {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
schemas Schema[]
|
schemas Schema[]
|
||||||
gameSystems GameSystem[]
|
gameSystems GameSystem[]
|
||||||
|
accounts Account[]
|
||||||
|
sessions Session[]
|
||||||
|
PublicationRevision PublicationRevision[]
|
||||||
|
followedSystems GameSystemFollows[]
|
||||||
|
|
||||||
name String?
|
name String?
|
||||||
username String? @unique
|
username String? @unique
|
||||||
@ -113,12 +113,18 @@ model User {
|
|||||||
emailVerified DateTime?
|
emailVerified DateTime?
|
||||||
passwordHash String?
|
passwordHash String?
|
||||||
image String?
|
image String?
|
||||||
accounts Account[]
|
|
||||||
sessions Session[]
|
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
PublicationRevision PublicationRevision[]
|
}
|
||||||
|
|
||||||
|
model GameSystemFollows {
|
||||||
|
gameSystemId String
|
||||||
|
gameSystem GameSystem @relation(fields: [gameSystemId], references: [id])
|
||||||
|
userId String
|
||||||
|
user User @relation(fields: [userId], references: [id])
|
||||||
|
|
||||||
|
@@id([userId, gameSystemId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Account {
|
model Account {
|
||||||
|
2
types.d.ts
vendored
2
types.d.ts
vendored
@ -83,7 +83,7 @@ type SchemaTypes = Record<string, TypeType>;
|
|||||||
type Schema = {
|
type Schema = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
schema: SchemaFields;
|
fields: SchemaFields;
|
||||||
types: SchemaTypes;
|
types: SchemaTypes;
|
||||||
gameSystemId?: string;
|
gameSystemId?: string;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user