mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +00:00
fix(ai-usage): resolve code review feedback for concurrency upsert and timeframe window
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[team_id,user_id,period_start]` on the table `ai_usages` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ai_usages_team_id_user_id_period_start_key" ON "ai_usages"("team_id", "user_id", "period_start");
|
||||
@@ -834,6 +834,7 @@ model AiUsage {
|
||||
user User? @relation("UserToAiUsage", fields: [userId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@map("ai_usages")
|
||||
@@unique([teamId, userId, periodStart])
|
||||
@@index([teamId, periodStart])
|
||||
@@index([teamId, userId, periodStart])
|
||||
}
|
||||
|
||||
+3
-3
File diff suppressed because one or more lines are too long
+8
-1
@@ -304,6 +304,7 @@ export type AiUsageOrderByWithRelationInput = {
|
||||
|
||||
export type AiUsageWhereUniqueInput = Prisma.AtLeast<{
|
||||
id?: string
|
||||
teamId_userId_periodStart?: Prisma.AiUsageTeamIdUserIdPeriodStartCompoundUniqueInput
|
||||
AND?: Prisma.AiUsageWhereInput | Prisma.AiUsageWhereInput[]
|
||||
OR?: Prisma.AiUsageWhereInput[]
|
||||
NOT?: Prisma.AiUsageWhereInput | Prisma.AiUsageWhereInput[]
|
||||
@@ -319,7 +320,7 @@ export type AiUsageWhereUniqueInput = Prisma.AtLeast<{
|
||||
updatedAt?: Prisma.DateTimeFilter<"AiUsage"> | Date | string
|
||||
team?: Prisma.XOR<Prisma.TeamScalarRelationFilter, Prisma.TeamWhereInput>
|
||||
user?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
}, "id">
|
||||
}, "id" | "teamId_userId_periodStart">
|
||||
|
||||
export type AiUsageOrderByWithAggregationInput = {
|
||||
id?: Prisma.SortOrder
|
||||
@@ -463,6 +464,12 @@ export type AiUsageOrderByRelationAggregateInput = {
|
||||
_count?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type AiUsageTeamIdUserIdPeriodStartCompoundUniqueInput = {
|
||||
teamId: string
|
||||
userId: string
|
||||
periodStart: Date | string
|
||||
}
|
||||
|
||||
export type AiUsageCountOrderByAggregateInput = {
|
||||
id?: Prisma.SortOrder
|
||||
teamId?: Prisma.SortOrder
|
||||
|
||||
Reference in New Issue
Block a user