Files
triggerdotdev--trigger.dev/packages/database
James Ritchie 4906fe9cf0 Run page links to tasks & replay run modal improvements (#1364)
* Removed the inline-code accessory from the logs when calling trigger or batchTrigger from a run

* Removed re2 from the v3 catalog

* Added a Root badge to the runs list

* Keep the side panel open when switching tasks & remove links from detail panel

* Root and parent task styling inspector

* Hide the root badge if the task isn’t the root

* margin between the dev not running message

* improved spacing of items

* Improved Root badge style

* Show a table of triggered runs in the inspector

* Add parentSpanId index to the TaskRun table

* Fix for the run inspector now opening when linked from another run/replay

* Triggered runs table has a max height

* Added a description to the replay run modal and improved the styling slightly

* Only include a bottom border when the triggered run table is more than 4 items

* Improved the triggered runs table borders

* Improved the tables so they can have an optional sticky header

* Added table types to storybook

* Fix for hover states on different backgrounds & runs table select cell
2024-09-27 12:14:44 +01:00
..
2023-08-11 15:51:54 +01:00
2023-08-11 15:51:54 +01:00

@trigger.dev/database

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.

How to add a new index on a large table

  1. Modify the Prisma.schema with a single index change (no other changes, just one index at a time)
  2. Create a Prisma migration using cd packages/database && pnpm run db:migrate:dev --create-only
  3. Modify the SQL file: add IF NOT EXISTS to it and CONCURRENTLY:
CREATE INDEX CONCURRENTLY IF NOT EXISTS "JobRun_eventId_idx" ON "JobRun" ("eventId");
  1. Dont apply the Prisma migration locally yet. This is a good opportunity to test the flow.
  2. Manually apply the index to your database, by running the index command.
  3. Then locally run pnpm run db:migrate:deploy

Before deploying

Run the index creation before deploying

CREATE INDEX CONCURRENTLY IF NOT EXISTS "JobRun_eventId_idx" ON "JobRun" ("eventId");

These commands are useful:

-- creates an index safely, this can take a long time (2 mins maybe)
CREATE INDEX CONCURRENTLY IF NOT EXISTS "JobRun_eventId_idx" ON "JobRun" ("eventId");
-- checks the status of an index
SELECT * FROM pg_stat_progress_create_index WHERE relid = '"JobRun"'::regclass;
-- checks if the index is there
SELECT * FROM pg_indexes WHERE tablename = 'JobRun' AND indexname = 'JobRun_eventId_idx';

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.