Delete Flow and its Data
During development, you may want to completely remove a flow and all its data to make breaking changes, clean up test data, or start fresh after experimenting. This operation is destructive and should only be used in development environments.
Using the Delete Function
Section titled “Using the Delete Function”The delete function accepts a flow slug parameter and removes all associated data:
pgflow.delete_flow_and_data(flow_slug TEXT)Example usage in local development:
-- Delete a specific flow and all its dataSELECT pgflow.delete_flow_and_data('analyze_website');This deletes the flow definition, all runs, queued messages, and task outputs for the specified flow.
Installing the Function
Section titled “Installing the Function”Install by running the SQL directly in your database using psql or Supabase Studio.
The Delete Function
Section titled “The Delete Function”Run this SQL to install the delete function:
/** * Deletes a flow and all its associated data. * WARNING: This is destructive and should only be used during development. * * @param flow_slug - The slug of the flow to delete */create or replace function pgflow.delete_flow_and_data( flow_slug TEXT) returns void language plpgsql as $$BEGIN -- Drop queue and archive table PERFORM pgmq.drop_queue(delete_flow_and_data.flow_slug);
-- Delete all associated data in the correct order DELETE FROM pgflow.step_tasks WHERE step_tasks.flow_slug = delete_flow_and_data.flow_slug; DELETE FROM pgflow.step_states WHERE step_states.flow_slug = delete_flow_and_data.flow_slug; DELETE FROM pgflow.runs WHERE runs.flow_slug = delete_flow_and_data.flow_slug; DELETE FROM pgflow.deps WHERE deps.flow_slug = delete_flow_and_data.flow_slug; DELETE FROM pgflow.steps WHERE steps.flow_slug = delete_flow_and_data.flow_slug; DELETE FROM pgflow.flows WHERE flows.flow_slug = delete_flow_and_data.flow_slug;
RAISE NOTICE 'Flow % and all associated data has been deleted', delete_flow_and_data.flow_slug;END$$;After Deleting
Section titled “After Deleting”Once you’ve deleted the flow:
- You can compile and deploy a fresh version without conflicts
- The flow slug becomes available for reuse
- All historical data is permanently lost
See Also
Section titled “See Also” Version your flows Safe flow updates for production
Tune deployed flows Adjust production flow settings