Merge branch 'dev' into tags-in-public-collection

This commit is contained in:
Daniel
2024-11-02 17:56:43 -04:00
committed by GitHub
73 changed files with 2271 additions and 417 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Subscription" ADD COLUMN "quantity" INTEGER NOT NULL DEFAULT 1;
@@ -0,0 +1,56 @@
/*
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;
@@ -0,0 +1,37 @@
/*
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;
@@ -0,0 +1,11 @@
/*
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";
@@ -0,0 +1,8 @@
/*
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";
@@ -0,0 +1,17 @@
-- 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;
+13 -3
View File
@@ -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,10 +35,14 @@ 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[]
pinnedLinks Link[] @relation("PinnedLinks")
createdLinks Link[] @relation("CreatedLinks")
createdCollections Collection[] @relation("CreatedCollections")
collectionsJoined UsersAndCollections[]
collectionOrder Int[] @default([])
whitelistedUsers WhitelistedUser[]
@@ -105,6 +109,8 @@ 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
@@ -132,7 +138,9 @@ model Link {
name String @default("")
type String @default("url")
description String @default("")
pinnedBy User[]
pinnedBy User[] @relation("PinnedLinks")
createdBy User? @relation("CreatedLinks", fields: [createdById], references: [id])
createdById Int?
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
tags Tag[]
@@ -171,8 +179,10 @@ 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
}