error: there is no transaction in progress
I created a drizzle table:
Which then generated this migration:
That creates this error when I try to use the migrator to run it.
It looks like transactions were generated to wrap around the enums, but not the create table or create indexes. Did I do something wrong here? Or is this error pointing to something else?
5 Replies
actually i solved that part. Turns out using Pool with the migrator makes it throw that error. So instead I tried using Client instead. Then that error goes away. However...
now i get:
I'm running this on Cockroach DB rather than Postgres, if that matters. I've been using Cockroach with my other Postgres apps and it hasn't been a problem, but I thought I'd bring it up in case.
ok, actually it does apparently matter. at least according to this post from 2020, CDB doesn't support the DO syntax.
https://github.com/jumpn/ecto_cockroachdb/issues/4
GitHub
syntax error at or near "do" - DO $$ BEGIN CREATE INDEX (...);EXCEP...
Hi! First of all, thanks for creating this adaptor! 🙂 I tried to use create_if_not_exists to create an index in an ecto migration, but it generates SQL that Cockroach doesn't seem to suppor...
We don't have Cockroach DB support yet. It should work with all common queries, so you can still try it. But we are not aware of all cases and Cockroach specifics yet. Just so you know
Regarding generated migration with
DO syntax
- it was our approach to execute migrations on table, that already had all types and tables from schema
We are going to add --strict
mode, that will disable any kind of DO syntax
To unblock you for now with Cockroach - you can modify sql file, by deleting DO
part. Just be sure, that you have modified this file BEFORE executing migrations on your database
So you can have this:
instead of this
We are allowing for such modifications in sql before executing it on database, just in case some sql generation is broken or even using unknown dialect for drizzle, like in your case. And it still won't block you in using drizzle for your needs
But anyway we have it in backlog and thanks so much for your feedback!I just started using cockroachdb and encountered this issue, has the
--strict
mode been implemented? is there a workaround for this other than removing the DO $$
?in my case I did the DO removal thing and it's working fine, thanks a lot