Skip to content
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

me: Make migrations not depend on default_int_size param #2751

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

tomhoule
Copy link
Contributor

@tomhoule tomhoule commented Mar 9, 2022

We use the cockroach-specific INT4 to avoid integer sizing
ambiguities. For the complete solution, we will have to deal with the
different type of autoincrementing primary keys, because two out of the three
that exist force INT8.

Addresses the default_int_size part of prisma/prisma#12113

@tomhoule tomhoule added this to the 3.11.0 milestone Mar 9, 2022
@tomhoule tomhoule marked this pull request as ready for review March 9, 2022 10:28
@tomhoule tomhoule requested a review from a team as a code owner March 9, 2022 10:28
Copy link
Contributor

@pimeys pimeys left a comment

Choose a reason for hiding this comment

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

I'm not sure about the direction here. We always enforce 32-bit keys?

PostgresType::Integer => "INTEGER".into(),
PostgresType::Integer => {
if flavour.is_cockroachdb() {
"INT4".into()
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we want INT4 keys always with CockroachDB?

@tomhoule
Copy link
Contributor Author

tomhoule commented Mar 9, 2022

I'll develop more in the commit message, but the gist of it is that we have Int and Bigint in the PSL. On all connectors, Int means 32 bit signed integer, and BigInt means 64 bit signed integer.

On Postgres, we map Int to INTEGER in a create table, and that's good and accurate.

On cockroachdb before this commit, we map Int to INTEGER, but the size of INTEGER depends on the default_int_size configuration (session or server) param, and by default it's 8. This commit goes around that by mapping int to INT4 to reflect Prisma expectations. BigInt is still mapped to BIGINTEGER, which is correct.

The gist of this commit is that we have Int and Bigint in the PSL. On all connectors, Int means 32 bit signed integer, and BigInt means 64 bit signed integer.

On Postgres, we map Int to INTEGER in a create table, and that's good and accurate.

On cockroachdb before this commit, we map Int to INTEGER, but the size of INTEGER depends on the default_int_size configuration (session or server) param, and by default it's 8. This commit goes around that by mapping int to INT4 to reflect Prisma expectations. BigInt is still mapped to BIGINTEGER, which is correct.

We use the cockroach-specific `INT4` to avoid integer sizing
ambiguities. For the complete solution, we will have to deal with the
different type of autoincrementing primary keys, because two out of the
there force INT8.

Addresses the default_int_size part of prisma/prisma#12113
@tomhoule tomhoule force-pushed the me/cockroachdb-default-create-tables branch from fd90b8a to 918d142 Compare March 9, 2022 11:25
@tomhoule tomhoule merged commit 9cc249f into main Mar 10, 2022
@tomhoule tomhoule deleted the me/cockroachdb-default-create-tables branch March 10, 2022 06:48
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.

None yet

2 participants