You must satisfy the constraint Items pKey

In the managed postgres db, I'm getting this error returned on an Insert a Record action query. Why does it want me to supply a primary key on a new item?

oh hmm… what does your query look like? i tried something like this just now and it worked for me:


Well mines a little longer, but all these values do resolve properly when the query is triggered. I used to supply “id” off of directly getting the max id from the db, but I want to get rid of that because it feels like a bad practice setting up onSuccess triggers waiting for that. I think this is an issue I’ve run into with the manageddb before, where some tables start refusing to accept new entries without a defined ID.

yeah i can definitely believe that. i feel like i ran into this before, but not sure exactly how to repro… i’ll take another look soon. is this blocking you btw?

I’ve got the workaround in, reading the highest ID and supplying ID + 1 as a declared ID value on creating a new entry. It works fine but feels less reliable and slower to me.

@abdul-nimeri
I’m in another position where this came up, but in a scenario where I need to generate a large bulk insert of items. I’m not particularly excited about the idea of calculating what the ids should be and using that in the insert. I’d like to try copying the table and deleting the original, but I need to figure out the sketchy way to do this through enabling editing in the managed db.

I made a copy of the table after enabling sql writing the the database. Now it doesn’t spit an error, however new items are added to the table with a null id.

Solved this by:

owned by tablename.measure_id; 
alter table tablename
alter column id set default nextval('measures_measure_id_seq'); 
commit;```

Solved this by:
create sequence measures_measure_id_seq
owned by tablename.measure_id;
alter table tablename
alter column id set default nextval(‘measures_measure_id_seq’);
commit;