add fk(orgId) for all create
This commit is contained in:
@@ -32,7 +32,7 @@ async function getProjectId(
|
||||
|
||||
const project = await db.project.findUnique({
|
||||
where: {
|
||||
organizationSlug: request.client?.organizationSlug,
|
||||
organizationId: request.client?.organizationSlug,
|
||||
id: projectId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -50,6 +50,7 @@ export async function POST(request: Request) {
|
||||
.filter((a) => typeof a === 'string')
|
||||
.map((projectId) => ({
|
||||
organizationSlug: membership.organizationId,
|
||||
organizationId: membership.organizationId,
|
||||
projectId: projectId,
|
||||
userId: user.id,
|
||||
level: AccessLevel.read,
|
||||
@@ -67,6 +68,7 @@ export async function POST(request: Request) {
|
||||
.filter((a): a is string => typeof a === 'string')
|
||||
.map((projectId) => ({
|
||||
organizationSlug: payload.data.organization.slug,
|
||||
organizationId: payload.data.organization.slug,
|
||||
projectId: projectId,
|
||||
userId: payload.data.public_user_data.user_id,
|
||||
level: AccessLevel.read,
|
||||
|
||||
@@ -41,6 +41,7 @@ export const clientRouter = createTRPCRouter({
|
||||
const secret = randomUUID();
|
||||
const data: Prisma.ClientCreateArgs['data'] = {
|
||||
organizationSlug: input.organizationSlug,
|
||||
organizationId: input.organizationSlug,
|
||||
projectId: input.projectId,
|
||||
name: input.name,
|
||||
type: input.type ?? 'write',
|
||||
|
||||
@@ -30,6 +30,7 @@ export const dashboardRouter = createTRPCRouter({
|
||||
id: await getId('dashboard', name),
|
||||
projectId: projectId,
|
||||
organizationSlug: organizationSlug,
|
||||
organizationId: organizationSlug,
|
||||
name,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -52,6 +52,7 @@ export const onboardingRouter = createTRPCRouter({
|
||||
id: await getId('project', input.project),
|
||||
name: input.project,
|
||||
organizationSlug: organization.id,
|
||||
organizationId: organization.id,
|
||||
types,
|
||||
},
|
||||
});
|
||||
@@ -61,6 +62,7 @@ export const onboardingRouter = createTRPCRouter({
|
||||
data: {
|
||||
name: `${project.name} Client`,
|
||||
organizationSlug: organization.id,
|
||||
organizationId: organization.id,
|
||||
projectId: project.id,
|
||||
type: 'write',
|
||||
cors: input.domain ? stripTrailingSlash(input.domain) : null,
|
||||
|
||||
@@ -98,7 +98,7 @@ export const organizationRouter = createTRPCRouter({
|
||||
db.projectAccess.deleteMany({
|
||||
where: {
|
||||
userId: input.userId,
|
||||
organizationSlug: input.organizationId,
|
||||
organizationId: input.organizationId,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
@@ -117,13 +117,14 @@ export const organizationRouter = createTRPCRouter({
|
||||
db.projectAccess.deleteMany({
|
||||
where: {
|
||||
userId: input.userId,
|
||||
organizationSlug: input.organizationSlug,
|
||||
organizationId: input.organizationSlug,
|
||||
},
|
||||
}),
|
||||
db.projectAccess.createMany({
|
||||
data: input.access.map((projectId) => ({
|
||||
userId: input.userId,
|
||||
organizationSlug: input.organizationSlug,
|
||||
organizationId: input.organizationSlug,
|
||||
projectId: projectId,
|
||||
level: 'read',
|
||||
})),
|
||||
|
||||
@@ -45,6 +45,7 @@ export const projectRouter = createTRPCRouter({
|
||||
data: {
|
||||
id: await getId('project', name),
|
||||
organizationSlug: organizationSlug,
|
||||
organizationId: organizationSlug,
|
||||
name: name,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ export const shareRouter = createTRPCRouter({
|
||||
create: {
|
||||
id: uid.rnd(),
|
||||
organizationSlug: input.organizationSlug,
|
||||
organizationId: input.organizationSlug,
|
||||
projectId: input.projectId,
|
||||
public: input.public,
|
||||
password: input.password || null,
|
||||
|
||||
Reference in New Issue
Block a user