Skip to content

Commit dcb19be

Browse files
committed
Add unique indexes for the oneTimeUseToken columns
1 parent 2892efa commit dcb19be

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[oneTimeUseToken]` on the table `TaskRun` will be added. If there are existing duplicate values, this will fail.
5+
6+
*/
7+
-- CreateIndex
8+
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "TaskRun_oneTimeUseToken_key" ON "TaskRun"("oneTimeUseToken");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[oneTimeUseToken]` on the table `BatchTaskRun` will be added. If there are existing duplicate values, this will fail.
5+
6+
*/
7+
-- CreateIndex
8+
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "BatchTaskRun_oneTimeUseToken_key" ON "BatchTaskRun"("oneTimeUseToken");

internal-packages/database/prisma/schema.prisma

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,6 @@ model TaskRun {
17231723
maxAttempts Int?
17241724
17251725
/// optional token that can be used to authenticate the task run
1726-
/// TODO: add a unique constraint on the token
17271726
oneTimeUseToken String?
17281727
17291728
batchItems BatchTaskRunItem[]
@@ -1791,8 +1790,7 @@ model TaskRun {
17911790
17921791
maxDurationInSeconds Int?
17931792
1794-
// TODO: uncomment this
1795-
// @@unique([oneTimeUseToken])
1793+
@@unique([oneTimeUseToken])
17961794
@@unique([runtimeEnvironmentId, taskIdentifier, idempotencyKey])
17971795
// Finding child runs
17981796
@@index([parentTaskRunId])
@@ -2168,7 +2166,6 @@ model BatchTaskRun {
21682166
batchVersion String @default("v1")
21692167
21702168
/// optional token that can be used to authenticate the task run
2171-
/// TODO: add a unique constraint on the token
21722169
oneTimeUseToken String?
21732170
21742171
///all the below properties are engine v1 only
@@ -2180,8 +2177,7 @@ model BatchTaskRun {
21802177
dependentTaskAttemptId String?
21812178
runDependencies TaskRunDependency[] @relation("dependentBatchRun")
21822179
2183-
// TODO: uncomment this
2184-
// @@unique([oneTimeUseToken])
2180+
@@unique([oneTimeUseToken])
21852181
///this is used for all engine versions
21862182
@@unique([runtimeEnvironmentId, idempotencyKey])
21872183
}

references/nextjs-realtime/src/app/page.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,7 @@ import { ImageUploadDropzone } from "@/components/ImageUploadButton";
66
import { auth } from "@trigger.dev/sdk/v3";
77

88
export default async function Home() {
9-
const publicAccessToken = await auth.createPublicToken({
10-
scopes: {
11-
write: {
12-
tasks: ["openai-streaming"],
13-
},
14-
},
15-
});
16-
17-
const readAll = await auth.createPublicToken({
18-
scopes: {
19-
read: {
20-
runs: true,
21-
},
22-
},
23-
});
24-
25-
console.log({ publicAccessToken, readAll });
9+
const publicAccessToken = await auth.createTriggerPublicToken("openai-streaming");
2610

2711
return (
2812
<main className="grid grid-rows-[1fr_auto] min-h-screen items-center justify-center w-full bg-gray-900">

0 commit comments

Comments
 (0)