Daniel
07/16/2020, 6:16 AMCREATE TABLE presets (
id SERIAL PRIMARY KEY,
uid character(5) NOT NULL REFERENCES tokens(uid) ON DELETE CASCADE,
deviceid integer NOT NULL,
data jsonb NOT NULL,
synced smallint NOT NULL DEFAULT 0,
isdeleted boolean NOT NULL DEFAULT false,
lfid integer,
error jsonb
);
Now when i am trying to delete a row on said tokens table
await prisma.tokens.delete({
where: {
uid
}
});
it gives me an violation error
Invalid `prisma.tokens.delete()` invocation in
path/dist/data.js:314:84
The change you are trying to make would violate the required relation 'tokens' between the `presets` and `tokens` models.
at PrismaClientFetcher.request (path/node_modules/@prisma/client/runtime/index.js:1:185690)
at process._tickCallback (internal/process/next_tick.js:68:7)
code: 'P2014',
meta:
{ relation_name: 'tokens',
model_a_name: 'presets',
model_b_name: 'tokens' } }
I am quite confused on what i am doing wrong, any tips appreciated.Darryl
07/16/2020, 7:28 AMRyan
07/16/2020, 9:11 AMuid foreign key field nullable. i.e. Remove the not null constraint.Daniel
07/16/2020, 9:28 AM