-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(schema-engine): disabled implicit transaction for batch statements starting from CockroachDB v22.2 #4632
feat(schema-engine): disabled implicit transaction for batch statements starting from CockroachDB v22.2 #4632
Conversation
…ts starting from CockroachDB v22.2
WASM Size
|
CodSpeed Performance ReportMerging #4632 will not alter performanceComparing Summary
|
✅ WASM query-engine: no benchmarks have regressedFull benchmark report
After changes in 4d137a7 |
// This test follows https://github.com/prisma/prisma-engines/pull/4632. | ||
#[test_connector(tags(CockroachDb))] | ||
fn decimal_to_boolean_migrations_work(api: TestApi) { | ||
let dir = api.create_migrations_directory(); | ||
|
||
let dm1 = r#" | ||
datasource db { | ||
provider = "cockroachdb" | ||
url = env("TEST_DATABASE_URL") | ||
} | ||
|
||
model Cat { | ||
id BigInt @id @default(autoincrement()) | ||
tag Decimal | ||
} | ||
"#; | ||
|
||
api.create_migration("create-cats-decimal", &dm1, &dir) | ||
.send_sync() | ||
.assert_migration_directories_count(1) | ||
.assert_migration("create-cats-decimal", move |migration| { | ||
let expected_script = expect![[r#" | ||
-- CreateTable | ||
CREATE TABLE "Cat" ( | ||
"id" INT8 NOT NULL DEFAULT unique_rowid(), | ||
"tag" DECIMAL(65,30) NOT NULL, | ||
|
||
CONSTRAINT "Cat_pkey" PRIMARY KEY ("id") | ||
); | ||
"#]]; | ||
|
||
migration.expect_contents(expected_script) | ||
}); | ||
|
||
let dm2 = r#" | ||
datasource db { | ||
provider = "cockroachdb" | ||
url = env("TEST_DATABASE_URL") | ||
} | ||
|
||
model Cat { | ||
id BigInt @id @default(autoincrement()) | ||
tag Boolean | ||
} | ||
"#; | ||
|
||
api.create_migration("migrate-cats-boolean", &dm2, &dir) | ||
.send_sync() | ||
.assert_migration_directories_count(2) | ||
.assert_migration("migrate-cats-boolean", move |migration| { | ||
let expected_script = expect![[r#" | ||
/* | ||
Warnings: | ||
|
||
- Changed the type of `tag` on the `Cat` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
|
||
*/ | ||
-- AlterTable | ||
ALTER TABLE "Cat" DROP COLUMN "tag"; | ||
ALTER TABLE "Cat" ADD COLUMN "tag" BOOL NOT NULL; | ||
"#]]; | ||
|
||
migration.expect_contents(expected_script) | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to the reviewer: although I expected this test to fail against main
when run on CockroachDB 23.1, it doesn't :/
This implies that somewhere in here we're not testing the "bad case for CockroachDB 22.2+" properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
for info, I added a new build in our docker image prismagraphql/cockroachdb-custom
for 23.1.13
https://hub.docker.com/r/prismagraphql/cockroachdb-custom/tags
That updated 23.1
as well, which should in theory be 23.1.13
too now.
Looks like it's now failing like in |
I see the failing tests having a It's currently unclear to me why updating a patch version of CockroachDB would result in such a disruptive change. |
Indeed, a revert sounds good as we can tackle this separately. |
This reverts commit b027610.
This PR closes prisma/prisma#20851.
It performs the same logic previously applied to CockroachDB v22.2 only, to any CockroachDB version equal or more recent than v22.2.
It also adds the CockroachDB-specific logic to parse the semantic versions. This implies that, at some point, we could disable the
enable_implicit_transaction_for_batch_statements
once a new major/minor version is reached.