Remove cockroach shadow db transaction#5669
Open
GustavoEdinger wants to merge 1 commit intoprisma:mainfrom
Open
Remove cockroach shadow db transaction#5669GustavoEdinger wants to merge 1 commit intoprisma:mainfrom
GustavoEdinger wants to merge 1 commit intoprisma:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR removes special CockroachDB transaction handling during shadow database migrations that was causing failures with certain migration sequences, specifically when adding enum values and then using them in subsequent migrations within the same transaction.
Key changes:
- Removes the
BEGIN;andCOMMIT;transaction wrapping for CockroachDB migrations in the shadow database - Eliminates special-case logic that violated CockroachDB's documented limitations around DDL statements in transactions
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #5669 will not alter performanceComparing Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request removes the special handling for CockroachDB when applying the migrations to the shadow db as it breaks under certain conditions, and it's against the recommendation from CockroachDB.
I understand that this reverts #5138, which was intended to speed up migrate dev.
Unfortunately, it breaks when the migrations in the project have the following steps:
The change in the type it's only avaialable after the it's committed due to cockroach limitations.
Here's an example of the error:
As stated in the documentation running inside a transaction is not supported by the database. https://www.cockroachlabs.com/docs/stable/online-schema-changes
The workaround suggested by the documentation would be to set
SET autocommit_before_ddl = on;which would auto commit the schema changes inside a transaction but that's only available from cockroachdb 24.1. Meaning prisma would have to set a min db version. https://www.cockroachlabs.com/docs/v24.1/online-schema-changes#enable-automatic-commit-before-running-schema-changes-inside-transactions/test-all