add team invitation functionality [WIP]
This commit is contained in:
@@ -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;
|
||||
+19
-3
@@ -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,15 @@ model User {
|
||||
image String?
|
||||
password String?
|
||||
locale String @default("en")
|
||||
parentSubscription Subscription? @relation("ChildUsers", fields: [parentSubscriptionId], references: [id])
|
||||
parentSubscriptionId Int?
|
||||
teamRole TeamRole @default(ADMIN)
|
||||
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[]
|
||||
@@ -72,6 +77,11 @@ model WhitelistedUser {
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
}
|
||||
|
||||
enum TeamRole {
|
||||
MEMBER
|
||||
ADMIN
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
@@ -104,6 +114,9 @@ model Collection {
|
||||
owner User @relation(fields: [ownerId], references: [id])
|
||||
ownerId Int
|
||||
members UsersAndCollections[]
|
||||
teamId Int?
|
||||
createdBy User? @relation("CreatedCollections", fields: [createdById], references: [id])
|
||||
createdById Int?
|
||||
links Link[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
@@ -131,7 +144,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[]
|
||||
@@ -173,6 +188,7 @@ model Subscription {
|
||||
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