Databaseprompt onlyMedium

Migration Until Clean

This loop automatically detects and fixes database migration issues by iteratively running migrations, analyzing errors, and applying corrective code changes until the migration process completes successfully.

← all loops
DatabaseMigrationDebuggingAutomationSchemaIterativeError HandlingDevOps

Goal

Fix migration issues

How to Run

Run this loop in a supported agent environment to automatically resolve database migration failures through iterative debugging and code fixes.

  1. 01

    Initialize Loop

    Provide the kickoff prompt to your coding agent in an environment like Cursor, Claude Code, or Gemini CLI.

  2. 02

    Agent Execution

    The agent will run the migration check, analyze failures, modify code, and repeat until success or max iterations reached.

Workflow Steps

  1. 01

    Run Migration Check

    Execute 'npm run migrate' to identify current migration status and errors

  2. 02

    Inspect Results

    Analyze the output for specific error messages, failed migrations, or schema conflicts

  3. 03

    Diagnose Issue

    Determine root cause: syntax errors, constraint violations, missing dependencies, or version conflicts

  4. 04

    Apply Fix

    Modify migration files, update dependencies, or adjust schema definitions to resolve identified issues

  5. 05

    Iterate Process

    Return to step 1 and repeat until migration succeeds or maximum attempts reached

Kickoff Prompt

Start the "Migration Until Clean" loop.

Goal: Fix migration issues
Max iterations: 10
Between iterations run: npm run migrate
Exit when: Migration succeeds


Start the Migration Until Clean loop. Run 'npm run migrate' to check current status, analyze any errors or failed migrations, identify the root cause of the issue, and apply appropriate fixes to migration files, schema definitions, or dependencies. Continue this process iteratively until the migration completes successfully or 10 iterations have been reached, whichever comes first. After each attempt, inspect the results carefully before making changes.

Self-pace this loop. After each iteration, run `npm run migrate` and evaluate the output, and only continue if the exit condition is not met (Migration succeeds). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.

Guardrails

hardcoded
  • ·Never execute destructive commands without user confirmation
  • ·Always backup the database before attempting fixes
  • ·Ensure rollback strategies exist for each migration change
  • ·Avoid modifying production data directly
  • ·Check for conflicting migration versions before applying changes
  • ·Validate schema integrity after each fix attempt

Flow Diagram

rendering…

Related loops — Database