Description
Overview
This cleanup automation workflow enables scheduled and manual deletion of outdated database records, providing reliable no-code integration for database maintenance. Designed for database administrators and DevOps teams, it automates the removal of execution logs older than 30 days from a MySQL table, triggered either on-demand or daily via a cron schedule.
Key Benefits
- Automates database record cleanup to reduce storage of obsolete execution data.
- Supports manual trigger and scheduled cron-based execution for flexible operation.
- Uses precise SQL query to delete records older than 30 days from the target table.
- Integrates directly with MySQL using stored credentials for secure access.
Product Overview
This automation workflow is designed to manage and optimize MySQL database storage by removing outdated records from the execution_entity table. It initiates via two triggers: a manual trigger node activated by user interaction, and a cron node configured to run daily at 7:00 AM. Upon activation, the workflow executes a MySQL query that deletes all rows where the stoppedAt timestamp is older than 30 days, using the SQL statement DELETE FROM execution_entity WHERE DATE(stoppedAt) < DATE_SUB(CURDATE(), INTERVAL 30 DAY). The workflow relies on stored MySQL credentials within n8n for secure database connectivity. Error handling behavior defaults to n8n’s platform standards, with no additional retry or backoff logic configured.
Features and Outcomes
Core Automation
This no-code integration pipeline accepts triggers either manually or on schedule, then runs a single SQL deletion query to clean up old records. The workflow employs deterministic logic with no branching or conditional steps.
- Single-pass evaluation executing a targeted DELETE query on demand or schedule.
- Deterministic outcome by removing all records with
stoppedAtolder than 30 days. - Synchronous execution of database commands without queuing or retries.
Integrations and Intake
The orchestration pipeline integrates n8n’s MySQL node authenticated via stored credentials. It receives triggers through a manual button press or a cron scheduler set at 7 AM daily. No additional input payloads or schema validation are required.
- MySQL node to connect and execute queries on the target database.
- Manual trigger node for user-initiated execution within n8n.
- Cron node configured for daily automated execution at a fixed hour.
Outputs and Consumption
Output consists of the execution result of the SQL DELETE query returned synchronously within n8n’s workflow context. No external data destinations or transformations are applied beyond the database operation.
- MySQL node returns query execution metadata following deletion.
- Synchronous response to trigger source with success or error data.
- No downstream output formatting or delivery to other services.
Workflow — End-to-End Execution
Step 1: Trigger
The workflow begins either manually via the “On clicking ‘execute'” manual trigger node or automatically through the “Cron” node, which fires daily at 7:00 AM. No additional headers or payloads are required to initiate the process.
Step 2: Processing
Input data passes through unchanged, as there is no transformation or validation logic implemented. The workflow proceeds directly to database execution upon trigger activation.
Step 3: Analysis
The SQL query executed deletes all records from execution_entity where the stoppedAt date is older than 30 days relative to the current date. This filtering is performed entirely within the database using the built-in date functions.
Step 4: Delivery
The workflow synchronously returns the result of the MySQL query execution to the origin trigger within n8n. No external delivery or further processing steps are included.
Use Cases
Scenario 1
Database logs accumulate over time, impacting storage and query performance. This automation workflow deletes records older than 30 days daily, maintaining database size and improving efficiency.
Scenario 2
System administrators require an on-demand cleanup option for execution logs. The manual trigger enables immediate deletion of outdated entries without waiting for scheduled runs.
Scenario 3
Operations teams seek to automate routine maintenance tasks. This workflow provides a reliable orchestration pipeline that runs unattended every morning to preserve database health.
How to use
To deploy this cleanup workflow, import it into your n8n instance and configure the stored MySQL credentials named “n8n” with appropriate database access rights. Activate the cron node to enable automatic daily execution at 7:00 AM or trigger manually via the user interface. Upon execution, the workflow will run the SQL deletion query and return result metadata within n8n. Monitor the workflow runs for any errors and verify database storage reduction over time.
Comparison — Manual Process vs. Automation Workflow
| Attribute | Manual/Alternative | This Workflow |
|---|---|---|
| Steps required | Manual SQL execution via client or script, multiple commands possible | Single automated step triggered manually or on schedule |
| Consistency | Subject to human error and timing variability | Deterministic daily execution and manual trigger option |
| Scalability | Limited by manual effort and scheduling complexity | Scales with database size via automated deletion query |
| Maintenance | Requires manual monitoring and script updates | Minimal maintenance; relies on n8n platform and credential validity |
Technical Specifications
| Environment | n8n workflow automation platform |
|---|---|
| Tools / APIs | MySQL database, n8n Manual Trigger, Cron node |
| Execution Model | Synchronous SQL query execution on trigger |
| Input Formats | Trigger events without payload |
| Output Formats | MySQL query execution metadata |
| Data Handling | Transient processing, no data persistence within workflow |
| Known Constraints | Relies on availability of MySQL database and credentials |
| Credentials | Stored MySQL credentials named “n8n” |
Implementation Requirements
- Configured n8n environment with access to target MySQL database.
- Valid stored MySQL credentials with DELETE permissions on
execution_entitytable. - Uninterrupted network connectivity between n8n instance and MySQL server.
Configuration & Validation
- Verify MySQL credentials within n8n have sufficient privileges to execute DELETE queries.
- Confirm cron node is set to trigger daily at 7:00 AM according to timezone settings.
- Test manual trigger node by executing workflow and checking database for expected record deletions.
Data Provenance
- Trigger nodes: “On clicking ‘execute'” (manual trigger) and “Cron” (scheduled daily at 7:00 AM).
- MySQL node executes DELETE query on the
execution_entitytable. - Workflow returns MySQL execution metadata including affected rows count.
FAQ
How is the cleanup automation workflow triggered?
The workflow triggers either manually via a user-initiated button press or automatically by a cron node configured to run daily at 7:00 AM.
Which tools or models does the orchestration pipeline use?
The orchestration pipeline uses n8n’s Manual Trigger and Cron nodes to initiate execution, and a MySQL node to run the cleanup SQL query.
What does the response look like for client consumption?
The response includes synchronous MySQL query execution metadata such as the number of deleted rows, returned within the n8n workflow context.
Is any data persisted by the workflow?
No data is persisted within the workflow; it only deletes records from the database and returns execution results transiently.
How are errors handled in this integration flow?
Error handling relies on n8n’s default platform behavior; no custom retry or backoff logic is configured in this workflow.
Conclusion
This cleanup automation workflow provides a dependable, no-code integration for maintaining MySQL database hygiene by deleting execution records older than 30 days. It offers both scheduled and manual triggers, ensuring flexible and consistent cleanup without manual intervention. The workflow’s operation depends on valid MySQL credentials and uninterrupted database availability, reflecting a clear trade-off requiring secure and reliable database access. Overall, it supports long-term database performance management through automated, deterministic execution.








Reviews
There are no reviews yet.