Updating/Inserting a record in Postgres if the record was found

Hello everyone,

I’m trying to create a workflow that pulls data from ClickUp and either inserts or updates a table in Postgres depending if the record already exists or not. There are times that the server where I’m hosting the Postgres database crashes so this workflow is to manually update/insert data that was updated in ClickUp during downtime.

I’m basically pulling the data from ClickUp and then searching each record individually using the split batch node. If the record exists already in the database then I should carry out the update operation with the data obtained from ClickUp. If the record doesn’t exist then I do an insert operation.

What I noticed though is that if I fetch the data and then search for the record, the output will now be replaced with whatever that query returns, losing all the information I had fetched from clickup previously.

I need help setting this up, specially on how to carry out the if operation and also persisting all the data that has been fetched from clickup.

Any help is appreciated.

Hi @Mauricio_Avalos :wave: Sorry to hear you’re having trouble with this!

Would you be able to add in some information that was requested in the template when you created a new topic? Specifically, could you let us know if you’re using n8n cloud or self-hosting (and how you’re self-hosting, if you are) as well as share your workflow? You can do that by selecting all your nodes, and then copying and pasting the data in a code block (with three backticks ``` before and after the code block, on a separate line). That would help to look into this for you!

1 Like

Hello Emerald,

Thank you for your reply. I was able to solve it by just adding the option to ignore failed inserts in the Postgres module, this essentially processes all data and fails when it has to. Since this is a workflow I will eventually run it will do for now :slight_smile:

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.