0

I am getting this error in Prisma Migrations. I know it's experimental but I need the migrations table in the database.

My Schema is as follows

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

generator client {
    provider = "prisma-client-js"
}

// a user can be an admin or a borrower or lender
enum Role {
    Lender
    Borrower
    Admin
}

model User {
    id        Int      @id @default(autoincrement())
    email     String   @unique
    name      String
    role      Role
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
}

First I ran npx prisma migrate save --experimental

Then npx prisma migrate up --experimental

The error I am getting is this.

Error: P1014

The underlying table for model _migration does not exist.

Also, the migrations table was in the database after I call npx prisma migrate save --experimental But after I run npx prisma migrate up --experimental , It's showing me this error.

Pranta
  • 2,928
  • 7
  • 24
  • 37
  • What version of `@prisma/client` and `@prisma/cli` are you using? Try again by installing the same latest version of both locally on a separate database to test. – Ryan Nov 09 '20 at 07:28
  • I am using 2.10.2 version of both @prisma/client and @prisma/cli. Also I reinstalled them and still won't work. – Pranta Nov 09 '20 at 08:37
  • Could you share the steps you followed along with the schema? – Ryan Nov 09 '20 at 11:32
  • updated, everything else works fine. Just that error and the migrations table is not in the database. – Pranta Nov 09 '20 at 13:09

1 Answers1

0

I tried the above schema with 2.10.2 and it works fine on a clean new DB. I would suggest trying again by removing the local migrations folder created by Prisma and checking with the following commands:

prisma migrate save --experimental
prisma migrate up --experimental

This should work on a clean DB without any tables.

Ryan
  • 5,229
  • 1
  • 20
  • 31