8

I need save DECIMAL(10,2) in database. In MySQL there is DECIMAL type.

MySQL docs:

https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html

Prisma 2.0 docs:

https://www.prisma.io/docs/reference/database-connectors/mysql

Possible Prisma 2.0 flows:

https://www.prisma.io/docs/understand-prisma/introduction#typical-prisma-workflows

  • I am using Prisma Migrate flow and see that mapping is constrained.
  • I see that it can be done in Introspection flow.

Are there any plans of support mysql data types like DECIMAL(10,2) in Prisma Migrate flow?

Daniel
  • 7,684
  • 7
  • 52
  • 76

2 Answers2

11

Full support for native types has been added in prisma/prisma@v2.15.0

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}
 
model Product {
  id Int @id @default(autoincrement())
  code String
  price Decimal @db.Decimal(9,2)
}
wobsoriano
  • 12,348
  • 24
  • 92
  • 162
0

Currently prisma migrate doesn't support the Decimal type. You can track the issue for custom DB types here

As a workaround, you would have to use a custom migration tool and specify the Decimal field that you require and then run prisma introspect which will get all the fields from your DB and populate the schema.prisma.

Ryan
  • 5,229
  • 1
  • 20
  • 31