feat: Support moving a user and it's teams to an org as temporary approach (#11892)
This commit is contained in:
1 parent
d46e80c2ac
commit
225055fb0c
9 files changed
+166
-20
No files matched your search
@@ -0,0 +1,19 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "RedirectType" AS ENUM ('user-event-type', 'team-event-type', 'user', 'team');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TempOrgRedirect" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"from" TEXT NOT NULL,
|
||||
"fromOrgId" INTEGER NOT NULL,
|
||||
"type" "RedirectType" NOT NULL,
|
||||
"toUrl" TEXT NOT NULL,
|
||||
"enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "TempOrgRedirect_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "TempOrgRedirect_from_type_fromOrgId_key" ON "TempOrgRedirect"("from", "type", "fromOrgId");
|
||||
@@ -972,3 +972,24 @@ model CalendarCache {
|
||||
@@id([credentialId, key])
|
||||
@@unique([credentialId, key])
|
||||
}
|
||||
|
||||
enum RedirectType {
|
||||
UserEventType @map("user-event-type")
|
||||
TeamEventType @map("team-event-type")
|
||||
User @map("user")
|
||||
Team @map("team")
|
||||
}
|
||||
|
||||
model TempOrgRedirect {
|
||||
id Int @id @default(autoincrement())
|
||||
// Better would be to have fromOrgId and toOrgId as well and then we should have just to instead toUrl
|
||||
from String
|
||||
// 0 would mean it is non org
|
||||
fromOrgId Int
|
||||
type RedirectType
|
||||
toUrl String
|
||||
enabled Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@unique([from, type, fromOrgId])
|
||||
}
|
||||
@@ -29,6 +29,13 @@ export const listHandler = async ({ ctx }: ListHandlerInput) => {
|
||||
},
|
||||
});
|
||||
|
||||
if (!membership) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "You do not have a membership to your organization",
|
||||
});
|
||||
}
|
||||
|
||||
const metadata = teamMetadataSchema.parse(membership?.team.metadata);
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user