feat: update migration script to drop old workflow tables with CASCADE - #350
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Reviewed changes
- Add CASCADE to workflow table drops: The migration now drops the five legacy workflow tables with
CASCADE, ensuring any FK constraints or dependent objects from a partially-completed prior migration run don't block the drop.
✅ No new issues found.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Migration
000027_add_automation_graph.sqlwas failing at startup with:PostgreSQL refuses a plain
DROP TABLEwhen any other object holds a dependency on the target table — in this caseworkflow_edgeshas two FK columns (source_node_id,target_node_id) that referenceworkflow_nodes(id). This can happen when a previous migration run was interrupted mid-transaction, leaving the dependency graph in a partially-applied state.Solution
Added
CASCADEto all fiveDROP TABLE IF EXISTSstatements in the workflow-cleanup section of the migration.CASCADEinstructs Postgres to automatically drop any dependent objects (foreign key constraints, indexes, views) along with the table, making the cleanup idempotent and resilient to whatever state the database is in from a prior partial run.This is safe because the explicit design decision in migration 000027 is to remove all old workflow data entirely — there is no production data worth preserving from the old workflow feature.
Changes
services/api/migrations/000027_add_automation_graph.sql— addedCASCADEto the fiveDROP TABLE IF EXISTSstatements that tear down the legacyworkflows/workflow_nodes/workflow_edges/workflow_status_rules/workflow_status_transitionstables.