* Record cold start and execution metrics on attempt executions. Add cold start metrics as span events on attempt spans and display them in the run dashboard * Add deployed tasks run timeline metrics * Add Dequeued event to run timeline and cleanup the run timeline code * Adds variants to storybook * WIP adding new span styles * Added offset progress bar animation * More storybook states * Adds support for the full vertical span to show the same state * Adds error state to timelineLine * Added additional state * Added more line styling * Added progress state to dequeued * Added another state to storybook * Fixed classname error * Updated styles for the span timeline points * Fixes alignment of timeline follow cursor indicator * Adds help text tooltip to timeline span type titles * Fixes type error * Tweaked wording of tooltips * Fixed type error (check this) * Moved isAdmin to a higher level * removed unused admin props * Removed unused Admin filter * Fixed border styling * made the opacity of the timeline states 30% less * Undo type cast * Added a diminished style that’s used for spans (grey progress bar) * Adds new storybook state * Fixed timeline state * Removed state if span isn’t the first * Changed the timestamp span icon --------- Co-authored-by: James Ritchie <james@trigger.dev>
@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 switch branches when you've done migrations
Sometimes you've applied migrations and then want to switch branches without wiping out your local database.
To do this you can run the following command:
DB_VOLUME=database-data-alt pnpm run docker
This will switch to the alt volume for your local database. This database will be blank if you haven't switched to this volume before, so you'll need to follow the normal steps (in the Contributing guide) to get setup, e.g. apply migrations and seed.
To switch back to the original volume, run the following command:
pnpm run docker
How to add a new index on a large table
- Modify the Prisma.schema with a single index change (no other changes, just one index at a time)
- Create a Prisma migration using
cd internal-packages/database && pnpm run db:migrate:dev --create-only - Modify the SQL file: add IF NOT EXISTS to it and CONCURRENTLY:
CREATE INDEX CONCURRENTLY IF NOT EXISTS "JobRun_eventId_idx" ON "JobRun" ("eventId");
- Don’t apply the Prisma migration locally yet. This is a good opportunity to test the flow.
- Manually apply the index to your database, by running the index command.
- 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.