Prisma Migrate prevents using special index functionality of CockroachDB.
See original GitHub issueProblem
We’d like to create an index that uses the STORING
clause, available in CockroachDB. Something like this:
CREATE INDEX "Reservation_foo_bar_idx" ON "Reservation"("foo", "bar") STORING ("col1", "col2", "col3", "col4");
We can add an index like this in schema.prisma
:
@@index([roomId, endDate])
and then edit the generated migration file to add the STORING
clause. But the next time the migrate dev
is run, the system will delete the old migration and replace it with one where the STORING
clause is not there.
Suggested solution
Extend index configuration to allow a storing
field for CRDB, or adjust Prisma Migrate to not delete the index when the introspection doesn’t exactly match on clauses that wouldn’t be recognized by Prisma Migrate anyway.
Alternatives
~Right now, what we’re doing is this:~
// @@index([roomId, endDate])
UPDATE this workaround doesn’t work either, Prisma Migrate will delete it.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Indexes - Prisma
GIN and BTree are the only index types supported by CockroachDB. The operator classes marked to work with CockroachDB are the only ones...
Read more >Using Prisma with CockroachDB
This guide discusses the concepts behind using Prisma and CockroachDB, explains the commonalities and differences between CockroachDB and other database ...
Read more >Adding Prisma Migrate to an existing project
Prisma Migrate will create a new migration directory with a SQL migration file in it: ... To include unsupported database features that already...
Read more >Prisma support for CockroachDB is now in Preview
Prisma Migrate is not supported yet with CockroachDB; if you're starting without an existing database, you will need to define the schema with...
Read more >Customize a migration file - Prisma
Make a schema change that requires custom SQL (for example, to preserve existing data) · Create a draft migration using: $npx prisma migrate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Migrate still drops it at the next generated migration, yeah.
AFAICT from the docs and the railroad diagram, that’s correct.
I am closing this here then, as I think #8584 asks for exactly this functionality. What you describe of it dropping it and replacing it with a normal index unless you modify the migration file is expected until that is implemented or we change the behavior otherwise.