Prisma migrate returns error for a field that was already removed

Hi, i'm using prisma with cokroachDB and I made a few changes to my schema and tried to migrate, but prisma returns an error that mentions a field that doesn't exist (it did exist in former migration). It seems to not realize that I've changed the schema. Can I delete all past migrations? maybe it'll help
25 Replies
Neto
Neto•3y ago
you can try to pull the schema and see what happens
Aviv
AvivOP•3y ago
it brought back an old version with that field
Neto
Neto•3y ago
yep so the field wasnt removed after all
Aviv
AvivOP•3y ago
yea but like what can I do? up until now I always migrated and it updated correctly
Neto
Neto•3y ago
you can remove the field from the schema migrate and check the db npx prisma studio if the field still there you should open an issue on github
Aviv
AvivOP•3y ago
When I load the studio, it says that the updated column: "does not exist in the current database.". I did remove the old one from the schema and tried to migrate, but like i've said, the migrate fails, it returns an errur that metionts the old column
Neto
Neto•3y ago
can you show the error?
Aviv
AvivOP•3y ago
the column that doesn't exist anymore is magicIds
Neto
Neto•3y ago
the error is on the migration itself for some reason []string !== string do you have the prisma vscode extension?
Aviv
AvivOP•3y ago
yes
Neto
Neto•3y ago
its just really weird prisma didnt get the correct migration
Aviv
AvivOP•3y ago
in my case I can clean the entire DB and mgirations if that will do any good
Neto
Neto•3y ago
you can try but the issue is the type itself the error is
Aviv
AvivOP•3y ago
yea i've since then changed the type
Neto
Neto•3y ago
[]string !== string
Aviv
AvivOP•3y ago
yea now I have Magic Magic[] on my character schema and: character Character? @relation(fields: [characterId], references: [id]) characterId String on my magic schema that's what i'm trying to update
Neto
Neto•3y ago
many to many?
Aviv
AvivOP•3y ago
maybe that's my mistake, like I wasn't sure if its many to many or not, in my case a character can have many magic, and magic can be used by many characters, is that many to many?
Neto
Neto•3y ago
yes many chars can have multiple magics many magics can belong to multiple chars
Neto
Neto•3y ago
TomDoesTech
YouTube
Learn Prisma Relationships (1-1, 1-m, m-m)
Prisma makes managing complicated relationships simple. By watching this video you will learn how to model and work with the most common relationships you will be creating in your applications. 0:00 Intro 1:28 One-to-one 9:09 One-to-many 16:01 Many-to-many 21:05 Many-to-many self reference Repository: https://github.com/TomDoesTech/prisma-rela...
Aviv
AvivOP•3y ago
Thanks a lot, will check that out! haven't done any backend thinking in a while 😅 Wow the migrations of the guy in the video are super fast, is this edited or just mine are slow? XD
Neto
Neto•3y ago
maybe the db in my experience mysql migrations are slow compared to pg
Aviv
AvivOP•3y ago
Hey your suggestion was great, I just have 1 more question. When I create a character, I want to also give it multiple existing magic. Ive seen the examples with: connect: { id: something, }, but it only adds one, based on the id I gave. How can I add an array of Ids?
Neto
Neto•3y ago
i think you can just add a [something1, something2]
Aviv
AvivOP•3y ago
That's weird, I did: magic: { connect: { id: [...magic], }, }, But got an error that it expects a string and got a list of strings. This is how magic is configured on the schema: magic Magic[]
Want results from more Discord servers?
Add your server