Tim Mensch
06/28/2021, 4:20 PMawait prisma.myTable.deleteMany();
...and I'm getting an error from Prisma. When I replace it with
await prisma.$executeRaw(`DELETE FROM "myTable";`);
It works fine. I'm using PostgreSQL. I really want to rely on Postgres to enforce any constraints, if only because, well, Postgres is going to do the foreign key constraint check anyway, and therefore whatever query Prisma is performing to verify the constraint is 100% wasted time.
This particular situation is easily worked around (and it's mostly irrelevant anyway, since it's part of the debug DB seed code); what worries me is any more "trying to be smart" queries Prisma might be doing every time any change is made to the data that mean we get 2-3x as many DB calls as actually required for an operation.
(As to why I was getting a bogus error: I'm using the "hacked" @view
approach to expose a MATERIALIZED VIEW
to Prisma. I don't actually care that the mapping isn't perfect, so it's not really relevant, unless somehow the @view
approach is causing the extra query above.)Ryan
06/29/2021, 7:14 AMjanpio
janpio
Tim Mensch
06/29/2021, 5:13 PMMATERIALIZED VIEW
, so that wouldn't exactly go over well.
But again: I'm asking about the general case. Can I tell Prisma to just never do the foreign key check? On any table ever? Because this is one place that any attempt to have JavaScript/TypeScript do the work of Postgres is strictly slowing things down and providing no value.janpio
janpio
migrate dev
or similar it will do stupid things (like create that fake model
as a table), you do not have to care what you write as onDelete
on that model - but of course I would make it be the same as what really happens - just for sanity)janpio
Tim Mensch
06/29/2021, 5:16 PMjanpio
Tim Mensch
06/29/2021, 5:17 PM