Letting duplicate slugs for teams to support orgs
This commit is contained in:
parent
a2de700f86
commit
c0bbae191a
|
@ -118,7 +118,7 @@ async function getTeamLogos(subdomain: string) {
|
|||
}
|
||||
// load from DB
|
||||
const { default: prisma } = await import("@calcom/prisma");
|
||||
const team = await prisma.team.findUnique({
|
||||
const team = await prisma.team.findFirst({
|
||||
where: {
|
||||
slug: subdomain,
|
||||
},
|
||||
|
|
|
@ -29,7 +29,7 @@ async function getIdentityData(req: NextApiRequest) {
|
|||
};
|
||||
}
|
||||
if (teamname) {
|
||||
const team = await prisma.team.findUnique({
|
||||
const team = await prisma.team.findFirst({
|
||||
where: { slug: teamname },
|
||||
select: { logo: true },
|
||||
});
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[slug,parentId]` on the table `Team` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[email,username]` on the table `users` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[username,organizationId]` on the table `users` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "Team_slug_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "users_email_idx";
|
||||
|
||||
|
@ -17,6 +21,9 @@ ALTER TABLE "Team" ADD COLUMN "parentId" INTEGER;
|
|||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "organizationId" INTEGER;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Team_slug_parentId_key" ON "Team"("slug", "parentId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "users_email_username_key" ON "users"("email", "username");
|
||||
|
||||
|
@ -29,12 +36,7 @@ ALTER TABLE "users" ADD CONSTRAINT "users_organizationId_fkey" FOREIGN KEY ("org
|
|||
-- AddForeignKey
|
||||
ALTER TABLE "Team" ADD CONSTRAINT "Team_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO
|
||||
"Feature" (slug, enabled, description, "type")
|
||||
VALUES
|
||||
(
|
||||
'organizations',
|
||||
true,
|
||||
'Manage organizations with multiple teams',
|
||||
'OPERATIONAL'
|
||||
) ON CONFLICT (slug) DO NOTHING;
|
||||
-- FeatureFlags
|
||||
INSERT INTO "Feature" (slug, enabled, description, "type")
|
||||
VALUES ('organizations', true, 'Manage organizations with multiple teams', 'OPERATIONAL')
|
||||
ON CONFLICT (slug) DO NOTHING;
|
|
@ -246,7 +246,7 @@ model Team {
|
|||
/// @zod.min(1)
|
||||
name String
|
||||
/// @zod.min(1)
|
||||
slug String? @unique
|
||||
slug String?
|
||||
logo String?
|
||||
appLogo String?
|
||||
appIconLogo String?
|
||||
|
@ -268,6 +268,8 @@ model Team {
|
|||
children Team[] @relation("organization")
|
||||
orgUsers User[] @relation("scope")
|
||||
webhooks Webhook[]
|
||||
|
||||
@@unique([slug, parentId])
|
||||
}
|
||||
|
||||
enum MembershipRole {
|
||||
|
|
Loading…
Reference in New Issue
Block a user