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 ?
No description
22 Replies
roze789
roze789OP•4w ago
My package.json
package.json
TravisTravis
TravisTravis•4w ago
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.
roze789
roze789OP•4w ago
my _journal.json contains this
{ "version": "7", "dialect": "postgresql", "entries": [] }
{ "version": "7", "dialect": "postgresql", "entries": [] }
and i ran drizzle-kit push but i get this error
TravisTravis
TravisTravis•4w ago
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.
roze789
roze789OP•4w ago
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
TravisTravis
TravisTravis•4w ago
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)
roze789
roze789OP•4w ago
exactly, i just tried again
Warning We've found duplicated index name across public schema. Please rename your index in either the products_wholesalers_relation table or the table with the duplicated index name
Warning We've found duplicated index name across public schema. Please rename your index in either the products_wholesalers_relation table or the table with the duplicated index name
i am getting this error with drizzle-kit generate
roze789
roze789OP•4w ago
No description
roze789
roze789OP•4w ago
no tables neither indexes
TravisTravis
TravisTravis•4w ago
Well if generate fails, that means it's definitely a problem with your schema (or at least drizzle)
roze789
roze789OP•4w ago
ok yes i tried with a simple table without relation and it did work message not very clear ...
TravisTravis
TravisTravis•4w ago
Yeah, that error message is weirdly vague.
roze789
roze789OP•4w ago
so all good. If someone goes here. Check your joins 😀 Thank you
TravisTravis
TravisTravis•4w ago
What ended up fixing it? It's not exactly a fix to just remove the relations.
roze789
roze789OP•4w ago
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
TravisTravis
TravisTravis•4w ago
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.
roze789
roze789OP•4w ago
my table look likes this
No description
roze789
roze789OP•4w ago
i used the new syntax to index but i should stay with the old one
Darren
Darren•4w ago
And those index names aren't used in your other tables?
roze789
roze789OP•4w ago
i dont know i guess it adds the table name before the index name
Darren
Darren•4w ago
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
roze789
roze789OP•4w ago
i redid my tables and it works without relations one or many to many relations is the issue
Want results from more Discord servers?
Add your server