Skip to content

feat(schema): add WorkerDeployment.externalId and task_runs_v2.external_deployment_id - #4661

Open
0ski wants to merge 1 commit into
mainfrom
oskar/feat-external-id-migrations
Open

feat(schema): add WorkerDeployment.externalId and task_runs_v2.external_deployment_id#4661
0ski wants to merge 1 commit into
mainfrom
oskar/feat-external-id-migrations

Conversation

@0ski

@0ski 0ski commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Migrations only, no code reads them yet. Postgres: nullable non-unique externalId on WorkerDeployment plus a CONCURRENTLY-built (environmentId, externalId) index in its own migration file. ClickHouse: external_deployment_id String DEFAULT '' on task_runs_v2 (plain String, not LowCardinality - commit SHAs are high-cardinality). Part of task run version skew protection (TRI-12998).

@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 603acad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The changes add external_deployment_id to ClickHouse task runs with reversible migration support. They also add optional externalId storage to Prisma WorkerDeployment records and define an index on environmentId and externalId.

Merge Risk: 🟡 Moderate · up to 603ac

The new PostgreSQL index migration can fail when deployed through the default transactional path because concurrent index creation requires a non-transactional execution path. Merge readiness depends on adjusting the migration or deployment procedure.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the schema changes but omits the required issue reference, checklist, testing, changelog, and screenshots sections. Add the required template sections, including the issue reference, completed checklist, testing steps, changelog entry, and screenshots or a stated reason they are not applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies both schema changes in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oskar/feat-external-id-migrations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]

This comment was marked as resolved.

@0ski
0ski marked this pull request as ready for review August 18, 2026 13:15
devin-ai-integration[bot]

This comment was marked as resolved.

…al_deployment_id

Migrations only, no code reads them yet. Postgres: nullable non-unique externalId on WorkerDeployment plus a CONCURRENTLY-built (environmentId, externalId) index in its own migration file. ClickHouse: external_deployment_id String DEFAULT '' on task_runs_v2 (plain String, not LowCardinality - commit SHAs are high-cardinality). Part of task run version skew protection (TRI-12998).
@0ski
0ski force-pushed the oskar/feat-external-id-migrations branch from 7625d61 to 603acad Compare August 18, 2026 18:50
@pkg-pr-new

pkg-pr-new Bot commented Aug 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@603acad

trigger.dev

npm i https://pkg.pr.new/trigger.dev@603acad

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@603acad

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@603acad

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@603acad

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@603acad

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@603acad

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@603acad

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@603acad

commit: 603acad

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f86bf16-4933-4e54-ad10-7f694b0ae9be

📥 Commits

Reviewing files that changed from the base of the PR and between 7625d61 and 603acad.

📒 Files selected for processing (4)
  • internal-packages/clickhouse/schema/040_add_task_runs_v2_external_deployment_id.sql
  • internal-packages/database/prisma/migrations/20260818120000_add_worker_deployment_external_id/migration.sql
  • internal-packages/database/prisma/migrations/20260818120100_add_worker_deployment_environment_id_external_id_index/migration.sql
  • internal-packages/database/prisma/schema.prisma
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal-packages/database/prisma/schema.prisma

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout. (21)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 12)
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: fk-cascade-guard / fk-cascade-guard
  • GitHub Check: code-quality / code-quality
  • GitHub Check: audit
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Build and publish previews
🧰 Additional context used
📓 Path-based instructions (2)
internal-packages/database/prisma/migrations/**/migration.sql

📄 CodeRabbit inference engine (internal-packages/database/CLAUDE.md)

internal-packages/database/prisma/migrations/**/migration.sql: When adding indexes to existing tables, use CREATE INDEX CONCURRENTLY IF NOT EXISTS to avoid production table locks.
Keep each CONCURRENTLY index in its own separate migration file, and add only one index per migration file.
Indexes on newly created tables may be created without CONCURRENTLY in the same migration as CREATE TABLE.
When adding an index for a new column on an existing table, use two migrations: first ALTER TABLE ... ADD COLUMN IF NOT EXISTS ..., then a separate migration containing CREATE INDEX CONCURRENTLY IF NOT EXISTS ....

Files:

  • internal-packages/database/prisma/migrations/20260818120000_add_worker_deployment_external_id/migration.sql
  • internal-packages/database/prisma/migrations/20260818120100_add_worker_deployment_environment_id_external_id_index/migration.sql
internal-packages/clickhouse/schema/[0-9][0-9][0-9]_*.sql

📄 CodeRabbit inference engine (internal-packages/clickhouse/CLAUDE.md)

internal-packages/clickhouse/schema/[0-9][0-9][0-9]_*.sql: Migration file numbering: name files as 0(N+1)_descriptive_name.sql where N is the largest existing migration number in schema/; rebase and renumber if main adds migrations before opening a PR
DDL in migrations must be idempotent: use ALTER TABLE ... ADD COLUMN IF NOT EXISTS, CREATE TABLE IF NOT EXISTS, DROP TABLE IF EXISTS, ADD INDEX IF NOT EXISTS, DROP INDEX IF EXISTS, and CREATE MATERIALIZED VIEW IF NOT EXISTS forms to allow out-of-order and retry-safe application

Files:

  • internal-packages/clickhouse/schema/040_add_task_runs_v2_external_deployment_id.sql
🧠 Learnings (2)
📚 Learning: 2026-02-03T18:48:31.790Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 2994
File: internal-packages/database/prisma/migrations/20260129162810_add_integration_deployment/migration.sql:14-18
Timestamp: 2026-02-03T18:48:31.790Z
Learning: For Prisma migrations targeting PostgreSQL: - When adding indexes to existing tables, create the index in a separate migration file and include CONCURRENTLY to avoid locking the table. - For indexes on newly created tables (in CREATE TABLE statements), you can create the index in the same migration file without CONCURRENTLY. This reduces rollout complexity for new objects while protecting uptime for existing structures.

Applied to files:

  • internal-packages/database/prisma/migrations/20260818120000_add_worker_deployment_external_id/migration.sql
  • internal-packages/database/prisma/migrations/20260818120100_add_worker_deployment_environment_id_external_id_index/migration.sql
📚 Learning: 2026-03-22T13:49:20.068Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3244
File: internal-packages/database/prisma/migrations/20260318114244_add_prompt_friendly_id/migration.sql:5-5
Timestamp: 2026-03-22T13:49:20.068Z
Learning: For Prisma migration SQL files under `internal-packages/database/prisma/migrations/`, it is acceptable to create indexes with `CREATE INDEX` / `CREATE UNIQUE INDEX` (i.e., without `CONCURRENTLY`) when the parent table is introduced in the same PR and has no existing production rows yet. Only require `CREATE INDEX CONCURRENTLY` (or otherwise account for existing production data/locks) when the table already exists in production with data.

Applied to files:

  • internal-packages/database/prisma/migrations/20260818120000_add_worker_deployment_external_id/migration.sql
  • internal-packages/database/prisma/migrations/20260818120100_add_worker_deployment_environment_id_external_id_index/migration.sql
🔇 Additional comments (2)
internal-packages/clickhouse/schema/040_add_task_runs_v2_external_deployment_id.sql (1)

1-7: LGTM!

internal-packages/database/prisma/migrations/20260818120000_add_worker_deployment_external_id/migration.sql (1)

1-1: LGTM!

@@ -0,0 +1 @@
CREATE INDEX CONCURRENTLY IF NOT EXISTS "WorkerDeployment_environmentId_externalId_idx" ON "public"."WorkerDeployment"("environmentId", "externalId");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "Prisma versions and migration configuration:"
for pattern in package.json prisma.config.ts pnpm-lock.yaml yarn.lock package-lock.json; do
  fd -t f -a -g "$pattern" . -x \
    rg -n -C 2 '`@prisma/`|prisma migrate deploy|migration' {}
done

echo "Migration deployment wrappers:"
rg -n -C 5 \
  --glob '*.yml' \
  --glob '*.yaml' \
  --glob '*.json' \
  --glob '*.js' \
  --glob '*.ts' \
  'prisma migrate deploy|migrate deploy|BEGIN|COMMIT|transaction' .

Repository: triggerdotdev/trigger.dev

Length of output: 1443


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "Relevant package manifests and Prisma configuration:"
fd -t f \( -g 'package.json' -o -g 'prisma.config.*' -o -g 'schema.prisma' \) . \
  -x sh -c 'echo "--- {}"; rg -n -C 4 "prisma|migrate|transaction|adapter" "{}" || true'

echo "Migration deployment references:"
rg -n -C 8 \
  --glob '*.yml' --glob '*.yaml' --glob '*.json' --glob '*.js' --glob '*.cjs' \
  --glob '*.mjs' --glob '*.ts' --glob '*.mts' --glob '*.sh' \
  'prisma migrate deploy|db:migrate:deploy|migrate deploy|PRISMA_MIGRATE|migration' .

echo "Migration directory structure and neighboring migration files:"
fd -t f 'migration.sql' internal-packages/database/prisma/migrations \
  | tail -n 12 \
  | while read -r f; do echo "--- $f"; sed -n '1,8p' "$f"; done

Repository: triggerdotdev/trigger.dev

Length of output: 329


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "Relevant package manifests and Prisma configuration:"
git ls-files | rg '(^|/)(package\.json|prisma\.config\.[^/]+|schema\.prisma)$' |
while IFS= read -r f; do
  echo "--- $f"
  rg -n -C 4 'prisma|migrate|transaction|adapter' "$f" || true
done

echo "Migration deployment references:"
rg -n -C 8 \
  --glob '*.yml' --glob '*.yaml' --glob '*.json' --glob '*.js' --glob '*.cjs' \
  --glob '*.mjs' --glob '*.ts' --glob '*.mts' --glob '*.sh' \
  'prisma migrate deploy|db:migrate:deploy|migrate deploy|PRISMA_MIGRATE|migration' .

echo "Migration directory structure and neighboring migration files:"
git ls-files 'internal-packages/database/prisma/migrations/*/migration.sql' |
  tail -n 12 |
  while IFS= read -r f; do
    echo "--- $f"
    sed -n '1,8p' "$f"
  done

Repository: triggerdotdev/trigger.dev

Length of output: 50382


🌐 Web query:

Prisma 6.14 migrate deploy CREATE INDEX CONCURRENTLY transaction PostgreSQL migration outside transaction

💡 Result:

In Prisma, PostgreSQL migrations are not inherently wrapped in a transaction by default [1][2][3]. However, there is nuance regarding how Prisma executes statements: it may sometimes execute multiple statements within a single block or connection state, which can lead to complications with operations that strictly forbid being inside a transaction block [4][2]. For PostgreSQL operations like CREATE INDEX CONCURRENTLY, which cannot run inside a transaction block, you must ensure the migration is executed outside of any transaction [5][4][2]. To achieve this in Prisma: 1. Manual Control: You can ensure a migration runs outside of a transaction by simply not wrapping your SQL in BEGIN and COMMIT statements [1][2]. If you are experiencing unexpected transaction behavior (such as when Prisma groups multiple statements), ensure your migration script specifically contains only the operation that requires being outside a transaction, or structure your SQL to explicitly avoid transaction blocks [4]. 2. Avoid Default Wrapping: Prisma does not add BEGIN/COMMIT to PostgreSQL migrations by default [1][3]. If you find your migration is being wrapped, inspect the generated migration.sql file to ensure no manual BEGIN/COMMIT statements were added, and verify that you are not running other commands in the same file that might trigger implicit transaction grouping [4]. 3. Migration Safety: When using operations like CREATE INDEX CONCURRENTLY, it is highly recommended to use tools like pgfence [5][6]. These tools analyze your migration files and help identify operations that require special handling, such as concurrent index creation, which can otherwise cause failures if executed within a transaction [5][6]. Note: While recent updates have focused on improving support for operations like CREATE INDEX CONCURRENTLY [7], the fundamental PostgreSQL requirement that these commands cannot run inside a transaction remains [5]. Always test your migrations in a staging environment to ensure the execution semantics match your expectations [6].

Citations:


🌐 Web query:

site:prisma.io/docs Prisma Migrate CREATE INDEX CONCURRENTLY transaction PostgreSQL

💡 Result:

Prisma Migrate does not automatically generate or support CREATE INDEX CONCURRENTLY statements in its standard schema-based migration workflow [1]. Because PostgreSQL requires that CREATE INDEX CONCURRENTLY cannot run inside a transaction block, you must manually customize your migrations to use this feature [1]. To implement this safely with Prisma Migrate, follow these steps: 1. Create a migration file without applying it: Use the --create-only flag when generating your migration [2][3]. 2. Modify the generated SQL: Open the resulting migration.sql file and replace the standard CREATE INDEX statement with CREATE INDEX CONCURRENTLY [1]. 3. Run outside a transaction: Since CREATE INDEX CONCURRENTLY cannot execute inside a transaction, you must ensure the migration is executed outside of the transaction block that Prisma typically wraps around migrations [1]. You may need to manually run the SQL statement against your database using a tool like psql or an administrative interface, as Prisma Migrate's standard execution flow for PostgreSQL involves wrapping migrations in a single transaction [4][5]. Using tools like pgfence can help identify when you should consider using CONCURRENTLY for indexes to avoid performance degradation caused by table-locking during index builds [1][6]. Because standard Prisma migrations are transactional by default on PostgreSQL, manual intervention is necessary for any PostgreSQL command that forbids being run within a transaction [4][1][5].

Citations:


🌐 Web query:

site:github.com/prisma/prisma CREATE INDEX CONCURRENTLY migrate deploy transaction Prisma 6

💡 Result:

Prisma does not natively support CREATE INDEX CONCURRENTLY [1][2]. Attempting to use this command within a Prisma migration typically fails because PostgreSQL prohibits CREATE INDEX CONCURRENTLY from running inside a transaction block [1][3][4], and Prisma often executes migrations within a transaction or groups multiple statements in a way that creates an implicit transaction block [5][6]. Because Prisma Migrate does not have a built-in mechanism to handle this requirement, developers generally use the following workarounds: 1. Separate the index creation: Move the CREATE INDEX CONCURRENTLY statement into its own standalone migration file [7][2]. When a migration file contains only a single statement, Prisma may avoid wrapping it in an implicit transaction, allowing the concurrent operation to succeed [5][7]. 2. Manual execution: Perform the CREATE INDEX CONCURRENTLY operation manually on the production database, then manually update the _prisma_migrations table to mark the corresponding migration as applied [1][4][8]. This prevents Prisma from attempting to run the index creation again during subsequent deployments [4]. 3. Modify the SQL: Edit the generated migration file to ensure no other commands are grouped with the CREATE INDEX CONCURRENTLY statement [5][7]. Note that if you modify migration files, you must also update the migration checksum in the _prisma_migrations table, or Prisma will detect a mismatch and refuse to deploy [1][2][8]. These manual interventions are necessary because Prisma's automatic migration runner is designed for atomic, transactional application of schema changes, which inherently conflicts with the architectural requirements of PostgreSQL concurrent index builds [9][6].

Citations:


🌐 Web query:

Prisma migrate deploy transaction source apply_migration raw_cmd PostgreSQL migration engine

💡 Result:

In the context of Prisma Migrate and PostgreSQL, the execution behavior is as follows: Prisma migrate deploy The prisma migrate deploy command is designed for production environments [1][2]. It applies all pending migrations found in your prisma/migrations directory that have not yet been recorded in the _prisma_migrations table [3]. It operates by serializing execution across concurrent processes using advisory locks (on PostgreSQL) to prevent multiple migration runs from interleaving [4][2]. Transaction Behavior On PostgreSQL, Prisma Migrate executes the entire migration run inside a single transaction [4]. If a migration fails, the entire transaction is rolled back, leaving the database in its original state before the run began [4]. While Prisma does not explicitly wrap every individual migration script in a BEGIN and COMMIT block by default [5][6], its engine design ensures that the deployment process remains atomic [4]. Historically, this was achieved via raw SQL execution paths (e.g., raw_cmd) [7][8], but the engine has evolved to use more controlled internal methods like apply_migration_script to better handle operations that cannot run inside transaction blocks, such as CREATE INDEX CONCURRENTLY [7]. Migration Engine Internals At the engine level (prisma-engines), the SqlSchemaConnector is responsible for applying migrations [9][10]. - raw_cmd: Historically used for executing raw SQL strings directly against the database [9][8]. - apply_migration / apply_migration_script: These are the higher-level internal methods used to apply migrations [9][8]. The migration engine uses these to handle the execution logic, which includes managing the migration state in the _prisma_migrations table [10][3] and ensuring that the schema is correctly updated [7]. In summary, when you run prisma migrate deploy on PostgreSQL, Prisma ensures atomicity for the deployment run by wrapping it in a transaction [4], while using internal engine methods to correctly handle specific SQL commands that have strict transactional requirements [7].

Citations:


🌐 Web query:

Prisma 6.14.0 migration-engine apply_migration PostgreSQL transaction source

💡 Result:

In Prisma, including version 6.14.0, the migration engine does not automatically wrap PostgreSQL migrations in a database transaction [1][2][3]. Key points regarding this behavior include: Default Non-Transactional Execution: By default, Prisma Migrate does not inject BEGIN or COMMIT statements into generated migration files [4][3]. This design choice is intended to ensure consistency across different database providers (some of which, like MySQL, do not support transactional DDL) and to provide flexibility [1][3]. Opt-in Transactional Behavior: If your migration requires atomicity, you can manually wrap the generated SQL in your migration file with BEGIN and COMMIT statements [5][6][3]. When you do this, Prisma will execute the contents of the file within that transaction block, provided the database engine supports it [2][5]. PostgreSQL Specifics: PostgreSQL supports transactional DDL. However, because Prisma does not explicitly control the transaction state for every migration, you are responsible for ensuring that the SQL commands you place inside a manual BEGIN/COMMIT block are compatible with being run in a transaction [7][2]. For example, some PostgreSQL commands, such as CREATE INDEX CONCURRENTLY, cannot run inside a transaction block and will fail if wrapped [7][4][2]. Internal Handling: The migration engine, specifically through the SqlSchemaConnector, handles the application of migration scripts [6][8][9]. While the engine itself maintains internal state (such as tracking progress in the _prisma_migrations table) to ensure it can resume failed migrations, it does not enforce a global transaction wrap for the migration files themselves [1][2]. If a manual transaction fails, the engine will report an error, and because the migration was wrapped in a transaction that was aborted, you may see errors related to the current transaction state being aborted, requiring you to resolve the migration manually [5][10].

Citations:


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT

curl -fsSL \
  'https://api.github.com/repos/prisma/prisma-engines/git/trees/6.14.0?recursive=1' >"$tmp"

echo "Migration application source paths:"
jq -r '.tree[]?.path' "$tmp" |
  rg 'migration-engine/.+(apply|migration|sql_schema_connector).+\.(rs|md)$' |
  head -n 80

echo "Relevant source references:"
for path in \
  migration-engine/connectors/sql-schema-connector/src/lib.rs \
  migration-engine/connectors/sql-schema-connector/src/apply_migration.rs \
  migration-engine/core/src/commands/apply_migrations.rs \
  migration-engine/core/src/commands/apply_migration.rs
do
  url="https://raw.githubusercontent.com/prisma/prisma-engines/6.14.0/$path"
  if body="$(curl -fsSL "$url" 2>/dev/null)"; then
    echo "--- $path"
    printf '%s\n' "$body" |
      rg -n -C 5 'apply_migration|raw_cmd|transaction|BEGIN|COMMIT|apply_migration_script' || true
  fi
done

Repository: triggerdotdev/trigger.dev

Length of output: 199


🏁 Script executed:

#!/usr/bin/env bash
set -u

echo "Prisma engine tag lookup:"
curl -fsSL 'https://api.github.com/repos/prisma/prisma-engines/tags?per_page=100' |
  jq -r '.[] | select(.name | test("6\\.14")) | [.name, .commit.sha] | `@tsv`' || true

echo "Prisma documentation wording:"
for url in \
  'https://www.prisma.io/docs/guides/integrations/pgfence' \
  'https://www.prisma.io/docs/orm/prisma-migrate/workflows/unsupported-database-features'
do
  echo "--- $url"
  curl -fsSL "$url" 2>/dev/null |
    sed 's/<[^>]*>/ /g' |
    tr -s '[:space:]' ' ' |
    rg -o -i '.{0,180}(transaction|concurrent|migration).{0,260}' |
    head -n 12 || true
done

Repository: triggerdotdev/trigger.dev

Length of output: 9969


🌐 Web query:

site:prisma.io/docs/guides/integrations/pgfence "outside a transaction block" "Prisma Migrate"

💡 Result:

Prisma Migrate typically runs migrations within a transaction block to ensure that if a migration fails, the changes are rolled back. However, certain SQL operations, such as CREATE INDEX CONCURRENTLY in PostgreSQL, are prohibited from running inside a transaction block [1]. When you need to perform such operations, you must manually edit the generated migration SQL file to include the required commands (e.g., adding CONCURRENTLY) and ensure the migration runs outside of a transaction [1]. Since Prisma Migrate applies migrations in a transaction by default, you may need to handle the execution of these specific, non-transactional SQL statements outside of the standard Prisma Migrate workflow if the tooling does not support disabling the transaction wrapper for individual migration files. For database safety when performing these operations, it is recommended to use tools like pgfence to analyze your migration files for dangerous patterns or unsupported operations before they are applied to your production database [1].

Citations:


🌐 Web query:

site:prisma.io/docs "Prisma Migrate runs migrations in a transaction" "CREATE INDEX CONCURRENTLY"

💡 Result:

Prisma Migrate does not natively support running CREATE INDEX CONCURRENTLY commands because this operation cannot be executed inside a standard transaction block [1], which is the default behavior for migrations in PostgreSQL [2][3]. When using PostgreSQL, Prisma Migrate wraps the execution of migration SQL files within a single transaction [2][3]. Because the PostgreSQL command CREATE INDEX CONCURRENTLY specifically requires that it not run inside a transaction block, attempting to include it in a standard Prisma migration will result in an error [1]. To use CREATE INDEX CONCURRENTLY with Prisma Migrate, you must manually modify the generated migration SQL file to remove the implicit transaction wrapping or ensure the statement is executed in a way that satisfies PostgreSQL requirements [1]. Specifically, if you modify a migration to include this command, you must be aware that the migration will no longer be atomic in the same way as standard migrations, as it must exist outside of the transaction block [1]. It is recommended to use database migration safety tools (such as pgfence) to analyze your migration files for heavy locking operations like standard index creation and to assist in generating the appropriate SQL for concurrent operations [1][4]. Note that Prisma's schema definition language does not currently provide a configuration option to automatically generate concurrent index migrations [5].

Citations:


Run this migration outside a transaction.

prisma migrate deploy runs migrations in a transaction by default, but PostgreSQL rejects CREATE INDEX CONCURRENTLY inside a transaction. Use a non-transactional deployment path for this migration.

Source: MCP tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants