You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Associate child runs with the parent span ID (#1352)
* Add safe rootTaskRunId index and a README to @trigger.dev/database
* Associate child runs with the span ID of the span in the parent run that triggered the child run
* Update deprecation notice doc links
`The "additionalFiles" option is deprecated and will be removed. Use the "additionalFiles" build extension instead. See https://trigger.dev/docs/guides/new-build-system-preview#additionalfiles for more information.`
231
+
`The "additionalFiles" option is deprecated and will be removed. Use the "additionalFiles" build extension instead. See https://trigger.dev/docs/config/config-file#additionalfiles for more information.`
`The "additionalPackages" option is deprecated and will be removed. Use the "additionalPackages" build extension instead. See https://trigger.dev/docs/guides/new-build-system-preview#additionalpackages for more information.`
242
+
`The "additionalPackages" option is deprecated and will be removed. Use the "additionalPackages" build extension instead. See https://trigger.dev/docs/config/config-file#additionalpackages for more information.`
`The "resolveEnvVars" option is deprecated and will be removed. Use the "syncEnvVars" build extension instead. See https://trigger.dev/docs/guides/new-build-system-preview#resolveenvvars for more information.`
278
+
`The "resolveEnvVars" option is deprecated and will be removed. Use the "syncEnvVars" build extension instead. See https://trigger.dev/docs/config/config-file#syncenvvars for more information.`
This is the internal database package for the Trigger.dev project. It exports a generated prisma client that can be instantiated with a connection string.
4
+
5
+
### How to add a new index on a large table
6
+
7
+
1. Modify the Prisma.schema with a single index change (no other changes, just one index at a time)
8
+
2. Create a Prisma migration using `cd packages/database && pnpm run db:migrate:dev --create-only`
9
+
3. Modify the SQL file: add IF NOT EXISTS to it and CONCURRENTLY:
10
+
11
+
```sql
12
+
CREATEINDEXCONCURRENTLY IF NOT EXISTS "JobRun_eventId_idx"ON"JobRun" ("eventId");
13
+
```
14
+
15
+
4. Don’t apply the Prisma migration locally yet. This is a good opportunity to test the flow.
16
+
5. Manually apply the index to your database, by running the index command.
17
+
6. Then locally run `pnpm run db:migrate:deploy`
18
+
19
+
#### Before deploying
20
+
21
+
Run the index creation before deploying
22
+
23
+
```sql
24
+
CREATEINDEXCONCURRENTLY IF NOT EXISTS "JobRun_eventId_idx"ON"JobRun" ("eventId");
25
+
```
26
+
27
+
These commands are useful:
28
+
29
+
```sql
30
+
-- creates an index safely, this can take a long time (2 mins maybe)
31
+
CREATEINDEXCONCURRENTLY IF NOT EXISTS "JobRun_eventId_idx"ON"JobRun" ("eventId");
32
+
-- checks the status of an index
33
+
SELECT*FROM pg_stat_progress_create_index WHERE relid ='"JobRun"'::regclass;
34
+
-- checks if the index is there
35
+
SELECT*FROM pg_indexes WHERE tablename ='JobRun'AND indexname ='JobRun_eventId_idx';
36
+
```
37
+
38
+
Now, when you deploy and prisma runs the migration, it will skip the index creation because it already exists. If you don't do this, there will be pain.
0 commit comments