Sync Test Factories and Fixtures with Database Migrations
This prompt updates your test factories, JSON fixtures, and contract tests to match new database schema changes, ensuring your test suite remains consistent with production code.
Agent prompt for ChatGPT and Claude
Prompt
mkdir -p .agents/skills/sync-test-factories-and-fixtures-with-database-migrations && curl -sL "https://prompts-gpt.com/prompts/sync-test-factories-and-fixtures-with-database-migrations/raw" -o .agents/skills/sync-test-factories-and-fixtures-with-database-migrations/SKILL.md---
name: sync-test-factories-and-fixtures-with-database-migrations
description: "This prompt updates your test factories, JSON fixtures, and contract tests to match new database schema changes, ensuring your test suite remains consistent with production code."
---
# Sync Test Factories and Fixtures with Database Migrations
This prompt updates your test factories, JSON fixtures, and contract tests to match new database schema changes, ensuring your test suite remains consistent with production code.
## Prompt
```
Act as a Senior Backend Engineer. Your task is to update the test suite to reflect recent database schema changes. Please ask the following 3 questions first and wait for my response: 1. Paste the SQL migration file content. 2. List the file paths of the factories, JSON fixtures, and contract test files that need updating. 3. Describe the specific changes in the migration, such as added columns, renamed fields, or dropped constraints. Once I provide these, perform the following: 1. Update the factory definitions to include the new fields with appropriate default values. 2. Add or update the mock JSON fixtures to match the new schema structure. 3. Update the contract tests to validate the new fields or handle removed ones. 4. Write only the modified code blocks with the file path header above each block. Output format: For each file, provide a header with the file path followed by a code block containing the updated logic. Ensure all changes maintain existing data types and relationships. This is not professional software engineering advice; verify all changes in a staging environment before deployment.
```
## Usage Notes
Use this in Cursor, ChatGPT, or Claude when a database migration breaks your test suite. Have your SQL migration file, factory definitions, and test files ready to paste.
Act as a Senior Backend Engineer. Your task is to update the test suite to reflect recent database schema changes. Please ask the following 3 questions first and wait for my response: 1. Paste the SQL migration file content. 2. List the file paths of the factories, JSON fixtures, and contract test files that need updating. 3. Describe the specific changes in the migration, such as added columns, renamed fields, or dropped constraints. Once I provide these, perform the following: 1. Update the factory definitions to include the new fields with appropriate default values. 2. Add or update the mock JSON fixtures to match the new schema structure. 3. Update the contract tests to validate the new fields or handle removed ones. 4. Write only the modified code blocks with the file path header above each block. Output format: For each file, provide a header with the file path followed by a code block containing the updated logic. Ensure all changes maintain existing data types and relationships. This is not professional software engineering advice; verify all changes in a staging environment before deployment.Example output
Tips and common edits
Why this works
- Forces structured inputs to prevent hallucination of schema details.
- Ensures cross-file consistency by requiring all affected paths upfront.
- Includes a safety warning to verify changes in staging.
Use this in Cursor, ChatGPT, or Claude when a database migration breaks your test suite. Have your SQL migration file, factory definitions, and test files ready to paste.
Common edits
- Adjust the test framework syntax if using something other than Jest.
- Add a rule to specifically handle migration rollback logic if needed.
Reuse it: Use in a workflowAdapt in the builder
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
More like this
Automated Dead Code Cleanup Plan for Codex Repositories
Get a systematic plan to identify and safely remove unused exports and dead code from your codebase using characterization tests to prevent regressions.
Design Mock Tool Fixtures for Agent Trajectory Testing
Generate deterministic mock tool responses to test agent decision trees, edge-case failures, and schema-breaking payloads without live API usage or costs.
Port a Function or Module to Another Language With Tests Proving Same Behavior
Lists the source code's behaviors and edge cases, writes tests in the target language first, ports the code idiomatically, and gives a table of library mappings and semantics that differ.
Design a Benchmark Harness for Claude Code Agent Accuracy
Create a structured testing framework to evaluate coding agent performance on pull requests using deterministic ground-truth verification.
Cursor Characterization-Test-First Refactor of a Legacy Module
Has Cursor lock in current behavior with characterization tests before restructuring a legacy module in small steps, so you can decide whether the refactor preserved behavior and is safe to merge.
Create Selective Pre-Commit Hooks for Claude Code
This prompt generates a bash script that triggers specific tests and typechecks only for packages modified in your current git branch.
- Decompose Framework Migrations into Subagent Work Batches
- Generate API Client Patches from OpenAPI Schema Diffs
- Generate Boundary Condition Unit Tests for GitHub Copilot
- Generate Database Migration and Rollback Specs for Coding Agents
- Generate Reproducible Bug Fix Specs for Coding Agents
- Perform Static Call Graph Trace Before Modifying Code