-8
@@ -1,8 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Collection" ADD COLUMN "icon" TEXT,
|
||||
ADD COLUMN "iconWeight" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Link" ADD COLUMN "color" TEXT,
|
||||
ADD COLUMN "icon" TEXT,
|
||||
ADD COLUMN "iconWeight" TEXT;
|
||||
@@ -1,3 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Collection" ALTER COLUMN "color" DROP NOT NULL,
|
||||
ALTER COLUMN "color" DROP DEFAULT;
|
||||
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Made the column `color` on table `Collection` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Collection" ALTER COLUMN "color" SET NOT NULL,
|
||||
ALTER COLUMN "color" SET DEFAULT '#0ea5e9';
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Subscription" ADD COLUMN "quantity" INTEGER NOT NULL DEFAULT 1;
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `_LinkToUser` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "TeamRole" AS ENUM ('MEMBER', 'ADMIN');
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "_LinkToUser" DROP CONSTRAINT "_LinkToUser_A_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "_LinkToUser" DROP CONSTRAINT "_LinkToUser_B_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Collection" ADD COLUMN "createdById" INTEGER,
|
||||
ADD COLUMN "teamId" INTEGER;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Link" ADD COLUMN "createdById" INTEGER;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "parentSubscriptionId" INTEGER,
|
||||
ADD COLUMN "teamRole" "TeamRole" NOT NULL DEFAULT 'ADMIN',
|
||||
ALTER COLUMN "name" DROP NOT NULL;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "_LinkToUser";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_PinnedLinks" (
|
||||
"A" INTEGER NOT NULL,
|
||||
"B" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "_PinnedLinks_AB_unique" ON "_PinnedLinks"("A", "B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_PinnedLinks_B_index" ON "_PinnedLinks"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "User" ADD CONSTRAINT "User_parentSubscriptionId_fkey" FOREIGN KEY ("parentSubscriptionId") REFERENCES "Subscription"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Collection" ADD CONSTRAINT "Collection_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Link" ADD CONSTRAINT "Link_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_PinnedLinks" ADD CONSTRAINT "_PinnedLinks_A_fkey" FOREIGN KEY ("A") REFERENCES "Link"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_PinnedLinks" ADD CONSTRAINT "_PinnedLinks_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Made the column `createdById` on table `Collection` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `createdById` on table `Link` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
|
||||
-- Update the Link table to set the createdBy based on the Collection's ownerId.
|
||||
UPDATE "Link"
|
||||
SET "createdById" = (
|
||||
SELECT "ownerId"
|
||||
FROM "Collection"
|
||||
WHERE "Collection"."id" = "Link"."collectionId"
|
||||
);
|
||||
|
||||
-- Set createdBy to ownerId for existing records
|
||||
UPDATE "Collection"
|
||||
SET "createdById" = "ownerId";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Collection" DROP CONSTRAINT "Collection_createdById_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Link" DROP CONSTRAINT "Link_createdById_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Collection" ALTER COLUMN "createdById" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Link" ALTER COLUMN "createdById" SET NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Collection" ADD CONSTRAINT "Collection_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Link" ADD CONSTRAINT "Link_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `teamRole` on the `User` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" DROP COLUMN "teamRole";
|
||||
|
||||
-- DropEnum
|
||||
DROP TYPE "TeamRole";
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `teamId` on the `Collection` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Collection" DROP COLUMN "teamId";
|
||||
@@ -1,17 +0,0 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Collection" DROP CONSTRAINT "Collection_createdById_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Link" DROP CONSTRAINT "Link_createdById_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Collection" ALTER COLUMN "createdById" DROP NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Link" ALTER COLUMN "createdById" DROP NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Collection" ADD CONSTRAINT "Collection_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Link" ADD CONSTRAINT "Link_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
+3
-18
@@ -27,7 +27,7 @@ model Account {
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
name String
|
||||
username String? @unique
|
||||
email String? @unique
|
||||
emailVerified DateTime?
|
||||
@@ -35,14 +35,10 @@ model User {
|
||||
image String?
|
||||
password String?
|
||||
locale String @default("en")
|
||||
parentSubscription Subscription? @relation("ChildUsers", fields: [parentSubscriptionId], references: [id])
|
||||
parentSubscriptionId Int?
|
||||
accounts Account[]
|
||||
collections Collection[]
|
||||
tags Tag[]
|
||||
pinnedLinks Link[] @relation("PinnedLinks")
|
||||
createdLinks Link[] @relation("CreatedLinks")
|
||||
createdCollections Collection[] @relation("CreatedCollections")
|
||||
pinnedLinks Link[]
|
||||
collectionsJoined UsersAndCollections[]
|
||||
collectionOrder Int[] @default([])
|
||||
whitelistedUsers WhitelistedUser[]
|
||||
@@ -98,8 +94,6 @@ model Collection {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
description String @default("")
|
||||
icon String?
|
||||
iconWeight String?
|
||||
color String @default("#0ea5e9")
|
||||
parentId Int?
|
||||
parent Collection? @relation("SubCollections", fields: [parentId], references: [id])
|
||||
@@ -108,8 +102,6 @@ model Collection {
|
||||
owner User @relation(fields: [ownerId], references: [id])
|
||||
ownerId Int
|
||||
members UsersAndCollections[]
|
||||
createdBy User? @relation("CreatedCollections", fields: [createdById], references: [id])
|
||||
createdById Int?
|
||||
links Link[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
@@ -137,15 +129,10 @@ model Link {
|
||||
name String @default("")
|
||||
type String @default("url")
|
||||
description String @default("")
|
||||
pinnedBy User[] @relation("PinnedLinks")
|
||||
createdBy User? @relation("CreatedLinks", fields: [createdById], references: [id])
|
||||
createdById Int?
|
||||
pinnedBy User[]
|
||||
collection Collection @relation(fields: [collectionId], references: [id])
|
||||
collectionId Int
|
||||
tags Tag[]
|
||||
icon String?
|
||||
iconWeight String?
|
||||
color String?
|
||||
url String?
|
||||
textContent String?
|
||||
preview String?
|
||||
@@ -178,10 +165,8 @@ model Subscription {
|
||||
stripeSubscriptionId String @unique
|
||||
currentPeriodStart DateTime
|
||||
currentPeriodEnd DateTime
|
||||
quantity Int @default(1)
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId Int @unique
|
||||
childUsers User[] @relation("ChildUsers")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user