Bharat Khaneja
03/07/2025, 10:50 AMMarvin
03/07/2025, 10:51 AMpg_cron
to schedule regular cleanup tasks safely. Be cautious with foreign key constraints to avoid breaking references.
3. Custom Script: A typical cleanup script might look like this:
sql
DELETE FROM flow_runs WHERE start_time < NOW() - INTERVAL '30 days';
DELETE FROM task_runs WHERE start_time < NOW() - INTERVAL '30 days';
-- Add similar queries for other tables if necessary
4. GitHub Discussions: There are ongoing discussions about database cleanup scripts and retention policies in the Prefect community. You can follow or contribute to these discussions for more insights. For instance, this GitHub issue discusses potential cleanup scripts.
5. Documentation & Resources:
- Self-hosted Prefect Management
- GitHub Issue on DB Cleanup
By carefully implementing a cleanup strategy, you can manage your database size effectively while ensuring that necessary flow data is retained.