prismaprisma-graphqlnexus-prisma

How to use DECIMAL(10,2) in prisma migrate tool?


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

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


Solution

  • 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)
    }