This prompt is designed for database migration agents and CI/CD pipelines that receive schema change requests containing conflicting column types, incompatible constraints, or contradictory migration directions. Its primary job is to act as a safety interlock: it analyzes a proposed schema change against the current database state and produces a structured conflict report before any Data Definition Language (DDL) is generated or executed. The ideal user is an AI agent or an automated workflow orchestrator that must prevent destructive schema changes, such as altering a column to two different data types in the same migration or adding a unique constraint to a column that is also being dropped.
Prompt
Contradictory Schema Change Detection Prompt

When to Use This Prompt
Define the job, the user, and the operational boundaries for the Contradictory Schema Change Detection Prompt.
Use this prompt when the cost of an incorrect schema change is high—for example, in production databases, multi-tenant systems, or regulated environments where data integrity is non-negotiable. It is appropriate when the input includes both the current schema (as a CREATE TABLE or equivalent DDL) and a proposed change expressed in natural language or a structured migration spec. The prompt is not a general-purpose SQL reviewer; do not use it for performance tuning, index recommendations, or syntax validation. It should be wired into a pre-commit or pre-deployment gate, where a failure to resolve conflicts blocks the pipeline and escalates to a human reviewer. The output is a machine-readable conflict report, not a corrected schema, ensuring that the resolution decision remains with a human operator.
Before integrating this prompt, ensure your harness can provide the current schema as ground truth and parse the structured conflict report to gate the next step. If your system cannot reliably extract the current schema or if schema changes are always applied by a human DBA with full context, this prompt adds unnecessary friction. The next step is to pair this detection prompt with a human review queue, where unresolved conflicts are packaged with the report and presented for adjudication. Avoid the temptation to let the model resolve conflicts autonomously; the prompt's value is in its refusal to guess.
Use Case Fit
Where the Contradictory Schema Change Detection Prompt works, where it fails, and what you need to run it safely.
Good Fit: Migration PR Review
Use when: A developer opens a pull request containing SQL migration files, and you need an automated first-pass review to catch conflicting column types, incompatible constraints, or contradictory migration directions before human review.
Guardrail: Run the prompt as a pre-review gate. Block the PR from merging if unresolved conflicts are detected and require explicit human resolution in the PR comments.
Good Fit: Multi-File Schema Reconciliation
Use when: A database migration agent receives multiple schema change requests across different files or services that touch the same tables, and you need to detect conflicts before generating any DDL.
Guardrail: Feed all pending change files into the prompt together. Require the conflict report to cite specific file names and line numbers so developers can trace each conflict to its source.
Bad Fit: Single-Statement Validation
Avoid when: You only need to validate a single ALTER TABLE statement for syntax correctness or best practices. This prompt is designed for detecting contradictions between multiple changes, not for linting individual statements.
Guardrail: Use a SQL linter or schema validation tool for single-statement checks. Reserve this prompt for multi-change conflict detection only.
Bad Fit: Runtime Schema Drift Detection
Avoid when: You need to detect schema drift between a running database and its expected state in production. This prompt works on proposed changes, not live system state.
Guardrail: Use a schema drift detection tool that compares live catalogs against version-controlled schemas. This prompt operates on change requests, not runtime observations.
Required Input: Complete Change Context
Risk: The prompt cannot detect contradictions if it only sees partial change requests. A missing migration file or an incomplete schema snapshot can hide real conflicts.
Guardrail: Require the full set of pending schema changes plus the current schema baseline as input. Validate input completeness before invoking the prompt. If any expected file is missing, halt and request it.
Operational Risk: Destructive Change Blindness
Risk: The prompt may detect type conflicts but miss destructive operations like DROP COLUMN or TRUNCATE that are not contradictory but are high-risk. A conflict-free report can create false confidence.
Guardrail: Add a separate destructive-change detection layer that flags DROP, TRUNCATE, and unqualified DELETE operations regardless of conflict status. Require explicit human approval for any destructive change, even when no contradictions are found.
Copy-Ready Prompt Template
A reusable prompt that detects contradictory schema changes and produces a structured conflict report before any DDL is generated.
This prompt template is designed for a database migration agent that receives schema change requests. Its job is to act as a safety gate: before any CREATE, ALTER, or DROP statements are generated, it must analyze the requested changes for internal contradictions. Contradictions include conflicting column types for the same column, mutually exclusive constraints (e.g., NOT NULL and DEFAULT NULL), or migration directions that cancel each other out (e.g., adding and dropping the same index in one request). The prompt instructs the model to produce a structured conflict report and halt execution, requesting human resolution. It does not generate DDL.
textYou are a database schema safety agent. Your only job is to detect contradictory instructions in a schema change request before any DDL is generated. You will receive a [SCHEMA_CHANGE_REQUEST] that may contain one or more proposed changes to a database schema. The current schema is provided in [CURRENT_SCHEMA] for reference. Analyze the request for the following contradiction types: 1. **Type Conflicts**: The same column is assigned two or more incompatible data types. 2. **Constraint Conflicts**: Mutually exclusive constraints are applied to the same column (e.g., NOT NULL and DEFAULT NULL, UNIQUE and a non-unique index). 3. **Directional Conflicts**: The request contains operations that cancel each other out (e.g., ADD COLUMN and DROP COLUMN for the same column, ADD INDEX and DROP INDEX for the same index). 4. **Dependency Conflicts**: A change references an object that another change in the same request drops. If no contradictions are found, output ONLY the following JSON: { "status": "clean", "conflicts": [] } If contradictions are found, output ONLY the following JSON. Do not generate any DDL, SQL, or migration code: { "status": "conflict", "conflicts": [ { "type": "TypeConflict | ConstraintConflict | DirectionalConflict | DependencyConflict", "description": "A clear, specific explanation of the contradiction.", "conflicting_instructions": [ "The first conflicting instruction from the request.", "The second conflicting instruction from the request." ], "affected_object": "The column, table, or constraint name.", "suggested_resolution_question": "A specific question asking the user to resolve this conflict." } ], "blocked_actions": ["List of specific DDL actions that are blocked due to conflicts."] } [CONSTRAINTS] - Never generate DDL, SQL, or migration code under any circumstances. - Never guess or assume a resolution. Your only output is the conflict report. - If the request is ambiguous but not strictly contradictory, treat it as clean and do not flag it. - Base all analysis on the provided [CURRENT_SCHEMA]. If a referenced object does not exist in the current schema, flag it as a DependencyConflict only if another instruction in the same request creates it.
To adapt this template, replace the placeholders with your application's actual inputs. [SCHEMA_CHANGE_REQUEST] should contain the raw user or system request, which may be natural language or a structured change list. [CURRENT_SCHEMA] should be a machine-readable representation of the existing schema, such as a CREATE TABLE dump or a JSON schema descriptor. The [CONSTRAINTS] section is critical for high-risk environments: it explicitly forbids DDL generation and resolution guessing. For additional safety, wire the output into a validator (see the Implementation Harness section) that confirms the JSON structure and blocks any downstream migration runner if status is conflict. If your system allows partial application of non-conflicting changes, extend the output schema to include a clean_changes array, but only after a human has resolved the flagged conflicts.
Prompt Variables
Required inputs for the Contradictory Schema Change Detection Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs will cause false negatives in conflict detection.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CURRENT_SCHEMA] | The existing database schema state as a DDL string, JSON schema, or structured table list that the change request will be compared against | CREATE TABLE users (id INT PRIMARY KEY, email VARCHAR(255) NOT NULL); | Must be non-empty and parseable as valid DDL or structured schema object. Reject if only a table name is provided without column definitions. |
[CHANGE_REQUEST] | The raw schema change request as submitted by the user, containing the intended modifications in natural language or DDL diff format | Change the email column to TEXT and make it nullable. Also rename id to user_id. | Must be non-empty string with at least one identifiable schema change intent. Reject if the request is a generic query like 'show me the schema' with no modification intent. |
[MIGRATION_DIRECTION] | The declared direction of the migration: forward, rollback, or bidirectional. Used to detect directional contradictions in the change request | forward | Must be one of: forward, rollback, bidirectional. Default to forward if not explicitly provided, but log a warning that direction was assumed. |
[TARGET_DIALECT] | The target SQL dialect or database engine for the migration. Used to validate type compatibility and constraint syntax | PostgreSQL 15 | Must match a known dialect from the allowed list: PostgreSQL, MySQL, SQLite, SQL Server, Oracle, BigQuery, Snowflake, Redshift. Reject unknown dialects. |
[EXISTING_CONSTRAINTS] | Any known constraints, indexes, foreign keys, or triggers on the affected tables that are not fully captured in the DDL | {"users": {"fk": ["orders.user_id"], "indexes": ["idx_users_email"], "triggers": ["trg_audit_users"]}} | Optional. If provided, must be valid JSON with table-level constraint mappings. Null allowed if no additional constraints exist beyond the DDL. |
[ALLOWED_BREAKING_CHANGES] | A policy flag indicating whether breaking changes are permitted or must be flagged as conflicts requiring human approval | Must be true or false. When false, any change that would cause data loss, type narrowing, or constraint violation must be reported as a conflict. When true, breaking changes are noted but not escalated. | |
[PREVIOUS_MIGRATION_LOG] | A log of recently applied or pending migrations on the same tables, used to detect sequencing conflicts and duplicate change requests | [{"version": "v3", "table": "users", "change": "Added last_login TIMESTAMP column", "status": "applied"}] | Optional. If provided, must be a JSON array of migration records with version, table, change, and status fields. Null allowed if no prior migrations exist. |
Implementation Harness Notes
How to wire the Contradictory Schema Change Detection Prompt into a database migration agent with validation, gating, and human review.
This prompt is designed to sit before any DDL generation in a database migration agent. When a user requests a schema change—whether through natural language, a PR comment, or a migration ticket—the agent must first pass the request through this prompt. The prompt's job is to detect contradictions in column types, constraints, migration directions, or naming that would produce destructive or invalid DDL if executed. The output is a structured conflict report, not SQL. The application harness must enforce that no DDL is generated until the conflict report is empty or resolved.
Wire the prompt into a pre-generation gate in your agent's tool-calling loop. The agent receives a schema change request and immediately calls a detect_schema_conflicts function that wraps this prompt. The function's input is the raw user request plus the current schema state (from INFORMATION_SCHEMA or a schema registry). The prompt returns a JSON object with a conflicts array and a resolution_required boolean. The harness must validate this output against a strict schema: each conflict must have a conflict_type (e.g., type_mismatch, constraint_conflict, direction_conflict), locations (affected tables/columns), and a description. If resolution_required is true, the agent must halt and present the conflict report to the user with a structured clarification request—never proceed to DDL generation. If resolution_required is false and the conflicts array is empty, the agent can proceed to the next step (DDL generation prompt). Implement a retry budget of 2 attempts for malformed JSON; if the prompt fails to produce valid JSON twice, escalate to a human reviewer with the raw response and the original request.
For production deployment, log every invocation with the input request, the current schema snapshot, the conflict report, and the resolution decision. This creates an audit trail for schema changes. Add an eval harness that tests the prompt against a golden dataset of contradictory and non-contradictory schema change requests. Measure precision (did we flag real conflicts?) and recall (did we miss any destructive conflicts?). Common failure modes include: false positives on legitimate type widening (e.g., INT to BIGINT), missed conflicts when the contradiction spans multiple tables, and hallucinated column names not present in the schema. Run these evals on every prompt version change. For high-risk environments (production databases, regulated data), require a second human approval after conflict resolution before any DDL executes, even if the prompt reports zero conflicts. The prompt is a safety net, not a replacement for migration review.
Expected Output Contract
Defines the exact JSON schema for the conflict report. Use this contract to validate the model's output before any DDL generation is allowed. Any field marked as required that is missing or fails its validation rule must trigger a retry or escalation.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
conflict_id | string (UUID v4) | Must be a valid UUID v4 string. Parse check. | |
status | enum: 'CONFLICT_DETECTED', 'NO_CONFLICT' | Must be one of the defined enum values. Schema check. | |
conflicting_requests | array of objects | Array must contain at least 2 objects. Length check. | |
conflicting_requests[].source_request_id | string | Must be a non-empty string. Null check. | |
conflicting_requests[].proposed_schema_snippet | string (SQL DDL) | Must be a non-empty string containing valid SQL DDL syntax. Parse check. | |
conflict_description | string | Must be a non-empty string with 10-300 words. Length and word count check. | |
resolution_question | string | Must be a non-empty string ending with a question mark. Format check. | |
recommended_action | enum: 'HALT', 'REQUEST_CLARIFICATION' | Must be 'HALT' if status is 'CONFLICT_DETECTED', otherwise 'REQUEST_CLARIFICATION'. Conditional check. |
Common Failure Modes
When detecting contradictory schema changes, these are the most common ways the prompt breaks in production and how to prevent each failure before it reaches a migration pipeline.
False-Positive Conflict on Compatible Changes
What to watch: The prompt flags a conflict when column types are actually compatible—such as widening VARCHAR(50) to VARCHAR(255) or INT to BIGINT. This blocks safe migrations and creates unnecessary review overhead. Guardrail: Include a compatibility matrix in the prompt that defines which type transitions are safe (widening, nullable additions) versus truly conflicting (type changes that lose data, incompatible collations). Validate flagged conflicts against this matrix before surfacing to a human.
Missed Conflict on Implicit Dependencies
What to watch: The prompt catches direct column conflicts but misses indirect ones—such as a foreign key column type change that breaks the referenced table's primary key, or a constraint removal that orphans an index. Guardrail: Extend the detection scope to include dependent objects. Require the prompt to enumerate foreign key relationships, indexes, views, and triggers that reference each changed column. Add a dependency check step before generating the conflict report.
Silent Default Application
What to watch: When the prompt encounters an underspecified change request, it fills in defaults (engine, charset, collation) without asking, producing a DDL that passes validation but doesn't match intent. Guardrail: Add a completeness gate that requires explicit values for storage engine, character set, collation, and default values before the prompt can produce a resolution recommendation. If any are missing, the output must be a clarification request, not a conflict report.
Directional Ambiguity in Migration Paths
What to watch: Two schema change requests specify opposite migration directions—one adds a column while another drops it, or one adds a NOT NULL constraint while another removes it. The prompt treats them as independent changes rather than contradictory intent. Guardrail: Require the prompt to build a net-change summary before conflict detection. Compare all requested operations against each other and flag any pair that cancels or reverses another. Surface the contradictory pair with the question: 'Which direction is intended?'
Context Window Truncation on Large Schemas
What to watch: For databases with hundreds of tables, the full schema plus change requests exceeds the context window. The prompt silently drops tables or constraints from consideration, missing conflicts on truncated objects. Guardrail: Implement a pre-filtering step that extracts only the tables, columns, and constraints referenced in the change requests plus their direct dependencies. If the filtered context still exceeds budget, split by schema or table group and run detection per batch with a cross-batch reconciliation step.
Over-Confidence on Destructive Change Classification
What to watch: The prompt classifies a change as 'safe' when it is actually destructive—such as changing a column type from TEXT to VARCHAR without checking for truncation risk, or dropping a column that is referenced in application code outside the schema. Guardrail: Add a destructive-change checklist to the prompt: for every type change, require a row-count check for values that would be truncated; for every column drop, require a search for references in views, stored procedures, and application code comments. Any unchecked assumption must escalate to human review with the specific risk stated.
Evaluation Rubric
Use this rubric to test the Contradictory Schema Change Detection Prompt before integrating it into a migration agent. Each criterion targets a specific failure mode that could lead to destructive DDL generation.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Direct Column Type Conflict | Prompt output identifies both conflicting type declarations, cites the column name, and requests resolution. Does not propose a default type. | Output suggests a merged type, picks one type silently, or omits the conflict. | Provide a change request with ALTER COLUMN [COLUMN_NAME] SET DATA TYPE VARCHAR and ALTER COLUMN [COLUMN_NAME] SET DATA TYPE INTEGER in the same batch. Check for explicit conflict flag. |
Mutually Exclusive Constraints | Prompt output lists the conflicting constraints, explains why they cannot coexist, and asks the user to choose one. | Output applies both constraints, drops one without asking, or generates DDL that would fail at commit. | Provide a request to add NOT NULL and DROP NOT NULL on the same column. Verify the output halts and requests a decision. |
Opposing Migration Directions | Prompt output detects that one change adds a table while another drops the same table. Halts and requests clarification on intended state. | Output sequences the operations, applies the last one, or generates a no-op. | Provide a CREATE TABLE [TABLE_NAME] and DROP TABLE [TABLE_NAME] for the same table in one request. Check for a halt signal and a conflict summary. |
Silent Default Application | Prompt output never invents a default value, type, or constraint when the request is ambiguous or silent on a required parameter. | Output generates DDL containing a guessed default, such as VARCHAR(255) when no length is specified. | Provide a request to add a column without a data type. Assert that the output asks for the type rather than generating any DDL. |
Conflict Report Structure Validity | Output is valid JSON matching the [CONFLICT_REPORT_SCHEMA] with all required fields populated and no extra fields. | Output is malformed JSON, missing required fields, or contains unstructured text outside the schema. | Run the output through a JSON schema validator against the expected conflict report schema. Assert strict validity. |
No-Conflict Pass-Through | Prompt output confirms no conflicts detected and returns an empty conflicts array without blocking the workflow. | Prompt fabricates a conflict, requests unnecessary clarification, or fails to return valid JSON. | Provide a coherent, non-conflicting schema change request. Assert that the conflicts array is empty and no halt signal is raised. |
Partial Conflict Handling | Prompt output reports only the conflicting changes and allows non-conflicting changes to proceed in a separate approved list. | Prompt output blocks the entire batch or conflates independent changes with the conflict. | Provide a batch with one conflicting pair and one independent valid change. Assert that the independent change is listed as non-conflicting and the conflict is isolated. |
Escalation Language Clarity | Prompt output explains the conflict in plain terms suitable for a human reviewer, not just raw DDL diffs. | Output contains only SQL snippets or cryptic error codes without a human-readable explanation. | Provide a complex multi-column conflict. Manually review the explanation field for clarity, completeness, and actionable guidance. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a simple JSON output schema. Focus on detecting the two most common conflict types: type mismatches and constraint collisions. Skip the migration-direction analysis and rollback-risk scoring. Run against a small set of hand-crafted DDL pairs.
Prompt snippet
code[SYSTEM]: You are a schema conflict detector. Given two schema change requests [CHANGE_A] and [CHANGE_B], identify if they conflict. Return JSON with `conflict_detected`, `conflict_type`, and `description`.
Watch for
- False positives on non-conflicting additive changes
- Missing conflicts when one change is a no-op
- Overly verbose descriptions that bury the conflict type

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us