DrizzleKit won't regenerate my schemas because of index keys
Hello,
I have issue with my drizzle.config.ts. I tried to regenerate it but I keep getting this error even if I remove my docker container and uninstall drizzle-kit from my package.json.
Error: We've found duplicated index name across public schema. Please rename your index in either the ..
Any idea ?
22 Replies
My package.json
Well it's telling you what to do.
Although I'm guessing it's a case of your DB being out of sync with either the drizzle migrations table in your DB or the data in your
drizzle/meta
directory.
As in drizzle thinks you haven't run the migration that adds that index.
So it's trying to create an already existing index.my _journal.json
contains this
and i ran drizzle-kit push
but i get this error
Now that I think about it, you didn't just give two indexes the same name in your schema, did you?
It's weird that the error tells you only one of the tables and doesn't tell you the index name.
no, even though I changed my indexes name, it shows this error
But it shouldn't show error if I remove and start a new docker container
that's why I cannot understand why I get this error
So to clarify, the DB is completely deleted, created new, and this error occurs when you run
push
?
You could maybe try running drizzle-kit generate
just to see if there is anything weird in the SQL.
(I don't really use push
, so maybe there's a better way to view the SQL it's running)exactly, i just tried again
i am getting this error
with drizzle-kit generate
no tables neither indexes
Well if
generate
fails, that means it's definitely a problem with your schema (or at least drizzle)ok yes
i tried with a simple table without relation
and it did work
message not very clear ...
Yeah, that error message is weirdly vague.
so all good. If someone goes here. Check your joins 😀
Thank you
What ended up fixing it?
It's not exactly a fix to just remove the relations.
ah
i cannot tell you
i just tried with a simple table
now i will do it step by step
i guess that it's my many to many table which conflict
It's interesting that the
relations
docs don't mention indexes, although it makes sense that it would add one.
I kind of wonder if this is a bug in drizzle, or a very poorly written error message at the least.my table look likes this
i used the new syntax to index but i should stay with the old one
And those index names aren't used in your other tables?
i dont know i guess it adds the table name before the index name
it doesn't add anything, you can check the sql, it uses that exact name for the index, so if it's the same in your other tables, then thats the error, check what sql is generated
i redid my tables and it works without relations
one or many to many relations is the issue