Hello! Does someone knows if it's possible to disa...
# prisma-migrate
l
Hello! Does someone knows if it's possible to disable transactions for a particular migration? I would like to build an index concurrently, but it's not possible to build it inside a transaction on PostgreSQL.
Copy code
Database error code: 25001

Database error:
ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
👀 1
j
Hey, what does you migration sql file look like besides the
CREATE INDEX CONCURRENTLY
?
l
it only contains a couple of
CREATE INDEX CONCURRENTLY
statements:
Copy code
CREATE INDEX CONCURRENTLY "UserEventFlags_eventId_idx" ON "UserEventFlags"("eventId");
...
r
I’m curious about this as well
j
Generally PostgreSQL migrations should not add a transaction around the transaction itself automatically (Afaik).
Do you have any indication there is really a transactions open besides the error message?
m
I’m running into this as well
j
I think someone opened an issue about this later, searching for "INDEX CONCURRENTLY" in the repo might help you find it.
🙌 1
m
I found a discussion referencing this thread and this issue that suggests running the migration manually and editing the checksum. Is this the preferred way of creating indices concurrently? It’d be great if I could run these migrations directly with Prisma so I can make a change to an index without incurring downtime in a production service.
j
It seems we are missing an actual feature request for
CREATE INDEX CONCURRENTLY
- so that would be great if you could create it.
Currently Prisma indeed has no support for this, so you need to make do manually somehow.
I am not sure if that variant is the best workaround, but it seems to work.
(Another thing I personally would try is to manually edit the migration and
COMMIT
the previous transaction, then run the
CREATE INDEX CONCURRENTLY
and then start another transaction - maybe you can "escape" the transaction context this way. [Might also just explode when you actually try that 😛 ])
m
Thanks! I did try adding a
COMMIT
to the beginning of my migration yesterday, but it failed with the same error. Will create a feature request for this today.
👍 1
j
Sorry for bringing up such an old discussion (I can start a new one if that’s preferred).
Has anybody found a workaround to this issue that is suitable for use in production?