question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma generating a NUMERIC(65, 30) for PostgreSQL, doesn't match docs

See original GitHub issue

Prisma 2 migrate autogenerated a column of Prisma’s Float type as a PostgreSQL Numeric with a precision of 65 and a scale of 30.

  1. The documentation says that this should be a real type in PostgreSQL, not a numeric
  2. Why is Prisma making such a precise column? This will result in massively more data consumption and will make calculations wildly slow compared to any other number type (see PostgreSQL documentation 8.1.2. Arbitrary Precision Numbers)

Edit: The generated migration Markdown file says it was attempting to create a Decimal(65,30), which I believe is just an alias for the Numeric type. Perhaps look through source code for that string?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
tomhoulecommented, Oct 1, 2020

@molomby this is what we are planning. The decimal situation is an old workaround for client tests that will be cleaned up.

0reactions
albertoperdomocommented, Feb 3, 2021

The idea that a migration could be created when the schema hasn’t changed, and that precision in stored data could be lost seems like a Bad Idea.

This is going to be indeed a breaking change we will have to carefully communicate to our users but we believe it’s for the best, because in the future we will be providing a better default. The way around the precision loss is indeed to introspect, which could be considered to some extent a codemod.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma generating a NUMERIC(65, 30) for PostgreSQL, doesn ...
Prisma 2 migrate autogenerated a column of Prisma's Float type as a PostgreSQL Numeric with a precision of 65 and a scale of...
Read more >
Prisma schema API (Reference)
Describes which generator to use. This can point to a file that implements a generator or specify a built-in generator directly. output, No,...
Read more >
PostgreSQL database connector (Reference) - Prisma
This page explains how Prisma can connect to a PostgreSQL database using the PostgreSQL database connector.
Read more >
Schema Incompatibilities | PostgreSQL - Prisma
Prisma 1 auto-generates values for DateTime fields when they're annotated with the @createdAt directive. These values are generated by the Prisma 1 server...
Read more >
PostgreSQL Data Types - Numeric, Text, and More - Prisma
The numeric type takes zero to two arguments. Specify precision followed by scale when configuring a column using both controls. PostgreSQL will round...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found