prisma / migrate

Issues for Prisma Migrate are now tracked at prisma/prisma. This repo was used to track issues for Prisma Migrate Experimental and is now deprecated.
https://www.prisma.io/docs/concepts/components/prisma-migrate
Apache License 2.0
767 stars 22 forks source link

Crash Report #618

Closed sethbrasile closed 3 years ago

sethbrasile commented 3 years ago

Hi Prisma Team! Prisma Migrate just crashed.

Command: npx prisma migrate save --experimental

Versions

Name Version
Platform darwin
Node v10.22.1
Prisma CLI 2.10.0
Binary af1ae11a423edfb5d24092a85be11fa77c5e499c

Error

Error: Error in migration engine.
Reason: [libs/sql-schema-describer/src/walkers.rs:214:27] index out of bounds: the len is 0 but the index is 0

Please create an issue in the migrate repo with
your `schema.prisma` and the prisma command you tried to use 🙏:
https://github.com/prisma/migrate/issues/new
generator client {
  provider = "prisma-client-js"
}

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

model User {
  id         Int       @id @default(autoincrement())
  firstName  String
  lastName   String
  email      String    @unique
  password   String
  messages   Message[]
  createdAt  DateTime  @default(now())
  updatedAt  DateTime  @updatedAt
}

model Message {
  id          Int      @id @default(autoincrement())
  body        String
  author      User     @relation(fields: [authorId], references: [id])
  recipient   User     @relation("recipient", fields: [recipientId], references: [id])
  authorId    Int      // relation scalar field  (used in the `@relation` attribute above)
  recipientId Int      // relation scalar field  (used in the `@relation` attribute above)
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}

Downgrade to Prisma CLI 2.9.0 resolved issue

MaksimKlepikov commented 3 years ago

Same after upgrading from 2.9.0 to 2.10.0

tomhoule commented 3 years ago

@sethbrasile I haven't been able to reproduce the crash with the schema you posted, do you have more context on how this happened? What sequence this was migrated in?

@kevrat could you share more context?

MaksimKlepikov commented 3 years ago

@sethbrasile I haven't been able to reproduce the crash with the schema you posted, do you have more context on how this happened? What sequence this was migrated in?

@kevrat could you share more context?

Just removed ./migrations and postgres db, recreate the db and the error went away

tomhoule commented 3 years ago

do you have a copy of the migrations folder before you removed it? It would help investigate the bug.

MaksimKlepikov commented 3 years ago

do you have a copy of the migrations folder before you removed it? It would help investigate the bug.

Unfortunately, I am don't commit the migrations folder yet

sethbrasile commented 3 years ago

I will attempt to recreate. If I recall correctly, I was receiving this error even with an empty/missing migrations folder. I believe I tried removing the existing migrations and resetting the db before I downgraded.

I did commit the migrations folder, so I do believe I have the state of the migrations folder in a commit. Not certain though. This is the start of a new project so it is hopefully in the initial commit.

tomhoule commented 3 years ago

There has been refactoring in that area of the codebase recently and there is generally a lot of work happening on migrate at the moment, so I am not surprised something broke. If it's possible, having that reproduction would really help figure things out, since I haven't been able to reproduce the problem in tests nor with manual testing. It's a pretty core part of migrate so it will be fixed soon regardless, but the reproduction would help. Thanks :)

tomhoule commented 3 years ago

We just released 2.10.1 with the fix. Can you confirm the crash does not happen anymore on your end?

kyler-hyuna commented 3 years ago

@tomhoule Have not seen it since I upgraded.

sethbrasile commented 3 years ago

Upgraded from 2.9.0 to 2.10.0, deleted migrations folder, deleted db, was able to save and up initial migration without error.

Added one field to one model. Ran npx prisma migrate save --experimental again, received same crash as original post.

Upgraded to 2.10.1, was able to save and up without error! I believe this is resolved! Thank you!