Hello guys. When im calling `prisma migrate` , I h...
# orm-help
m
Hello guys. When im calling
prisma migrate
, I have next error. Because prisma try to apply seed before apply migrations. How I can apply migration without seeds?
r
@Mykyta Machekhin 👋 What command are you using to create the migration?
m
prisma migrate dev
In the context of this problem, there is another. Why does prisma constantly want to drop my database even though history is synced? For example, on the slide between command calls, I did not make any changes, I just called the migrate command 2 times in a row. However, the second time, the prisma still wants to clear the database.
r
I cannot reproduce this. Could you check if
@prisma/client
and
prisma
is on the latest version i.e. 2.20.1? Also is you migrate command running under a script where seed is being called explicitly?
Have you separately made changes to the migration history? If you are only using
prisma migrate
commands then this should not happen.
m
r
For the seeding, I cannot reproduce it so it would be great if you could provide a minimal repo with the reproduction so that I can check. As for the drift, I would suggest creating an issue here with the reproduction steps so that we can look into this.
m
@Ryan answer to 2 question. I just tried the following: I completely dropped the database, and deleted all migrations. After that, I ran the command:
prisma migrate dev
. And I got an offer to clear the database, which is normal behavior. A migration has been generated that completely creates the schema from the file
prisma.schema
. But when I run the command a second time, I expect that the prisma will not want to delete the database.
r
Yes that should not happen. Could you share the database that you are using and the schema?
m
I use postgres. Schema is very large. Do you need it entirely?
r
In that case, you can create an issue above with the entire schema so that we can check it. As for the seeding, you can send me just the minimal repo so I can check that.
m
@Ryan I sent my schema in direct message
r
I’ve asked the team and we would need to look into this entirely so best create an issue 🙂
m
I found the problem. But a question arose. The problem was that I created the
_prisma_seeds
system table to add the incremental seed logic. As soon as I deleted it, the prisma stopped demanding to clean up the database. Tell me, is it possible to create such table?
r
Yes it’s possible, as long as you have the table in your
schema.prisma
.
Any models not present in your schema will make your schema drift from the database.
m
Thank! Thanks to your tips, I figured out what the problem was. Model names cannot start with an underscore. Therefore, the prisma couldn`t synchronize the schema and the database after I created the __prrisma__seed table in the database
💯 1
r
Awesome 💯