Custom Archiving/Deleting of n8n executions from PostgreSQL

Describe the problem/error/question

I want to write a custom handler for deleting or archiving old n8n executions from PostgreSQL. Is there any file in which I can modify to perform this task?
I am aware of the EXECUTIONS_DATA_PRUNE_MAX_COUNT environment variable but I wanted to know how the deleting exactly works.

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: Version 0.204.0
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: MacOS

Hey @anupamdungdung,

Welcome to the community :cake:

If you wanted to handle it directly in n8n then it is probably worth starting here: https://github.com/n8n-io/n8n/blob/master/packages/cli/src/databases/repositories/execution.repository.ts#L456 but it may be worth thinking about doing it outside of n8n instead so that you don’t need to modify code that you may not understand it will also be easier than keeping a fork up to date if we change something in this area in the future.

1 Like

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