| title | Delete Flow and its Data | ||||
|---|---|---|---|---|---|
| description | Completely remove a flow and all its data during development | ||||
| sidebar |
|
||||
| next |
|
import { Aside, Code, CardGrid, LinkCard } from "@astrojs/starlight/components"; import deleteFlowFunctionCode from '@/../../core/supabase/tests/_shared/delete_flow_and_data.sql.raw?raw';
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.
This permanently deletes all flow data including: - All run history - All queued and archived messages - All task outputs - All flow definitionsNever use this in production. Use versioned flows instead (e.g., my_flow_v1, my_flow_v2) to safely deploy changes while maintaining complete flow history.
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 data
SELECT pgflow.delete_flow_and_data('analyzeWebsite');This deletes the flow definition, all runs, queued messages, and task outputs for the specified flow.
This function is not included in default pgflow migrations to prevent accidental deployment to production. It has been thoroughly unit tested, but you must manually add it to your development database using the SQL in the [Delete Function](#the-delete-function) section below.Install by running the SQL directly in your database using psql or Supabase Studio.
Run this SQL to install the delete function:
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