Supern8n LogoSupern8n

Automate Aged Package Record Cleanup & Optimize Databases

Automate the daily cleanup of aged package records, eliminating manual data retention efforts by 100% and ensuring optimal database performance.

Manually purging aged data from critical databases is a tedious, error-prone task that can impact system performance and compliance. This workflow automatically identifies and archives old package records in MySQL databases daily or on demand, ensuring data hygiene and optimized database operations.

Telegram
Webhook Trigger
FREE
Ready-to-use workflow template
Complete workflow template
Setup documentation
Community support

Documentation

Automated Aged Package Record Cleanup

This n8n workflow provides a robust solution for maintaining database hygiene by automatically identifying and archiving outdated package records. It's ideal for businesses that manage high volumes of package data and need to ensure their databases remain lean, efficient, and compliant with data retention policies, all while keeping relevant teams informed.

Key Features

  • Automated Data Archiving: Automatically identifies and marks old 'TRANSPORTE-RECEBIDO' package records for archival after one month.
  • Multi-Database Support: Cleans records across distinct MySQL database instances (PPM and OBJ in this example).
  • Flexible Triggering: Can be scheduled for daily cleanup (e.g., every morning) or triggered on-demand via a webhook.
  • Real-time Notifications: Informs the relevant team via Telegram immediately after each database cleanup operation is completed.
  • Prevents Database Bloat: Regularly removes irrelevant data, helping to optimize database performance and reduce storage costs.

How It Works

This workflow can be initiated in three ways: on a daily schedule (e.g., 8 AM), manually via the 'execute' button, or on-demand through a specific webhook endpoint (`/limparPacotes`). Once triggered, the workflow simultaneously connects to two separate MySQL databases. For each database, it executes a SQL query that identifies all 'pacoteProduto' records with the 'TRANSPORTE-RECEBIDO' status that are older than one month. These identified records are then updated to set their 'modulo' field to 'DELETE', effectively archiving or marking them for future purging. Upon successful completion of the cleanup operation for each database, a confirmation message is sent to a specified Telegram chat, providing real-time updates on the data hygiene status.

Workflow Details

Category:DevOps & IT
Last Updated:Dec 16, 2025

Frequently Asked Questions