Inferensys

Prompt

Enum Value Modification Impact Prompt

A practical prompt playbook for using the Enum Value Modification Impact Prompt in production AI workflows to prevent application errors and data corruption.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Identify the right moment and required context before running an enum modification impact analysis.

This prompt is designed for backend and data engineering teams who are planning to modify an existing enum type in a production database schema. The job-to-be-done is a structured, pre-flight impact analysis that surfaces every downstream dependency before a migration PR is opened. The ideal user is a senior engineer or tech lead who understands the schema but needs a systematic way to map the blast radius of adding, removing, renaming, or reordering enum values. Required context includes the current enum definition, the proposed change, the database dialect (PostgreSQL, MySQL, etc.), and access to application code or ORM model definitions that reference the enum.

You should use this prompt when the change is more complex than appending a new value to the end of an existing enum. Specifically, run it before reordering values (which changes ordinal positions), removing or renaming values (which breaks existing data rows and application constants), or adding values in a position-sensitive way. The prompt is also appropriate when the enum is exposed through an API contract—REST, GraphQL, or gRPC—where client code may deserialize values by string or integer representation. Do not use this prompt for trivial documentation-only changes or for enums that are purely internal with no persistence, no API exposure, and no sort-order dependency.

Before running this prompt, gather the current enum definition, the proposed migration DDL, and a representative sample of application code that references the enum. If your ORM generates enum mappings automatically, include those generated files. The prompt works best when you can provide concrete code references rather than abstract descriptions. After receiving the impact analysis, validate each identified risk surface against your actual codebase and test suite. The analysis is a starting point for your migration checklist, not a replacement for integration tests or staging environment validation. Avoid using this prompt as a post-incident forensic tool—it is designed for prevention, not root cause analysis after a breaking change reaches production.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Enum Value Modification Impact Prompt delivers reliable analysis and where it creates a false sense of security.

01

Good Fit: Application Code Impact Analysis

Use when: you need to map every reference to an enum across repositories, ORM models, switch statements, and serialization logic. Guardrail: feed the prompt a grep or static analysis output of all enum references rather than asking it to guess where the enum is used.

02

Good Fit: Client Deserialization Risk

Use when: mobile, web, or third-party clients deserialize enum values and may break on unrecognized constants. Guardrail: provide the prompt with your API spec or generated client code so it can trace deserialization paths and flag unknown-value handling gaps.

03

Bad Fit: Runtime Behavior Prediction

Avoid when: you need to predict how production traffic will actually behave after an enum change. The prompt cannot observe real request patterns. Guardrail: pair the prompt's static analysis with production sampling or shadow traffic replay before concluding impact is low.

04

Bad Fit: Implicit ORM Enum Mappings

Avoid when: your ORM infers enum mappings from database column types or annotations that are not visible in application code. Guardrail: extract the actual ORM-generated mapping or schema introspection output and include it in the prompt context; do not rely on the model to infer framework conventions.

05

Required Input: Enum Definition and All References

Risk: incomplete input produces incomplete impact analysis. Guardrail: the prompt harness must collect the enum definition, every codebase reference, API schema fragments, and database column definitions before invocation. Missing any source creates blind spots.

06

Operational Risk: Sort Order and Ordinal Dependence

Risk: reordering enum values or inserting new ones can silently corrupt data if application logic depends on ordinal position rather than value name. Guardrail: the prompt must explicitly flag any ordinal-dependent logic found in the codebase and recommend switching to name-based comparison before the migration proceeds.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt template for analyzing the impact of modifying enum values in a database schema, with placeholders for your specific context.

This prompt template is designed to produce a structured JSON impact analysis when you are planning to add, remove, or reorder enum values in a database schema. It forces the model to consider application code references, existing data compatibility, sort order changes, and client deserialization risks across API boundaries. The output is a risk-ranked list of findings with explicit remediation steps, suitable for inclusion in a migration plan review.

text
You are a senior backend engineer and database reliability specialist. Your task is to perform a rigorous impact analysis for a proposed modification to an enum type in a database schema.

## INPUT CONTEXT
- **Enum Definition (Current):**
  [CURRENT_ENUM_DEFINITION]
- **Enum Definition (Proposed):**
  [PROPOSED_ENUM_DEFINITION]
- **Database Table and Column:**
  [TABLE_NAME].[COLUMN_NAME]
- **Application Code References:**
  [CODE_REFERENCES]
- **API Contract (if applicable):**
  [API_CONTRACT]
- **Existing Data Sample (first 20 rows):**
  [EXISTING_DATA_SAMPLE]

## OUTPUT SCHEMA
Return a single JSON object with the following structure:
{
  "change_summary": "string describing the net change (ADDED, REMOVED, REORDERED)",
  "compatibility_assessment": "BACKWARD_COMPATIBLE | BREAKING | REQUIRES_DATA_MIGRATION",
  "findings": [
    {
      "id": "F-001",
      "category": "CODE_REFERENCE | DATA_INTEGRITY | SORT_ORDER | CLIENT_DESERIALIZATION | API_CONTRACT",
      "severity": "CRITICAL | HIGH | MEDIUM | LOW",
      "location": "file:line or table:row reference",
      "description": "clear explanation of the risk",
      "remediation": "specific fix or migration step required"
    }
  ],
  "migration_script_required": true/false,
  "recommended_migration_steps": ["ordered list of steps"],
  "rollback_risk": "LOW | MEDIUM | HIGH",
  "rollback_notes": "explanation of rollback complexity"
}

## CONSTRAINTS
- If an enum value is being REMOVED, you MUST check the existing data sample for rows that currently use that value. Flag every such row as a CRITICAL finding.
- If the sort order is changing, you MUST identify any application code that relies on ordinal position (e.g., `.ordinal()` in Java, `enum_index` in ORMs) and flag it as HIGH severity.
- If the enum is exposed in an API contract (REST, GraphQL, gRPC), you MUST assess client deserialization risk. Unknown enum values may cause client crashes or data loss.
- Do not assume the application code handles unknown enum values gracefully. Explicitly check for default cases, exception handlers, and fallback logic.
- If no code references are provided, state that as a limitation and recommend a full codebase search before proceeding.

## RISK LEVEL
[HIGH_RISK]

## INSTRUCTIONS
1. Compare the current and proposed enum definitions value by value.
2. Classify the change type (add, remove, reorder).
3. For each code reference provided, determine if it is affected by the change.
4. Analyze the existing data sample for compatibility with the proposed definition.
5. Assess API contract and client deserialization risks.
6. Produce the JSON output with no additional commentary outside the JSON object.

To adapt this template, replace the square-bracket placeholders with your specific context. The [CURRENT_ENUM_DEFINITION] and [PROPOSED_ENUM_DEFINITION] should include the full enum type definition, including any comments. For [CODE_REFERENCES], provide a grep or search result showing every file and line where the enum is referenced in application code, ORM models, and serialization logic. The [EXISTING_DATA_SAMPLE] should be the output of SELECT [COLUMN_NAME] FROM [TABLE_NAME] LIMIT 20; to give the model real data to validate against. If this is a high-risk migration on a production table, set [RISK_LEVEL] to HIGH_RISK to trigger stricter analysis; otherwise, use MEDIUM_RISK. After pasting the adapted prompt into your AI harness, validate the output JSON against the schema before using it in your migration review. For production-critical changes, always have a human DBA or senior engineer review the findings before executing any migration script.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder required by the Enum Value Modification Impact Prompt, its purpose, a concrete example, and actionable validation rules to integrate into your harness before calling the model.

PlaceholderPurposeExampleValidation Notes

[ENUM_DEFINITION]

The current enum definition including schema, table, column, and all allowed values in order

schema.orders, table: order_status, column: status, values: ('pending','confirmed','shipped','delivered','cancelled')

Parse check: must contain schema, table, column, and a non-empty ordered list of values. Reject if values list is empty or contains duplicates.

[PROPOSED_CHANGE]

Description of the modification being proposed: add, remove, reorder, or rename enum values

Remove 'pending' and add 'draft' as first value. Reorder so 'draft' comes before 'confirmed'.

Parse check: must contain at least one action verb (add, remove, reorder, rename). Reject if change description is empty or matches current state exactly.

[CODEBASE_CONTEXT]

Relevant application code references, ORM model definitions, and API serialization logic that reference the enum

models/order.py line 42: status = Column(Enum(OrderStatus)); api/schemas/order_schema.py line 18: status: OrderStatus; frontend/order-list.tsx line 67: filter by status

Schema check: each reference must include file path and line number or function name. Reject if no code references provided. Null allowed only if codebase scan returned zero results.

[EXISTING_DATA_SAMPLE]

Representative sample of existing data in the enum column including value distribution counts

SELECT status, COUNT(*) FROM orders GROUP BY status; Results: pending: 14203, confirmed: 8912, shipped: 45231, delivered: 128900, cancelled: 3401

Parse check: must include value-to-count mapping. Validate that all values in sample exist in [ENUM_DEFINITION] current values list. Reject if sample is empty or counts are negative.

[API_CONSUMERS]

List of known API consumers, client SDKs, or downstream services that deserialize this enum

mobile-app v2.4+, partner-api v1.9, internal-dashboard, data-warehouse-etl, notification-service

Schema check: each consumer must have a name identifier. Null allowed if no known consumers. Warn if list is empty when enum is exposed via public API.

[SORT_ORDER_REQUIREMENT]

Whether the application relies on enum ordinal position for sorting, comparison, or range queries

true - dashboard uses ORDER BY status for pipeline view; reporting uses status >= 'shipped' for fulfillment metrics

Boolean parse check: must be true or false. If true, require evidence of sort dependency (code reference or query example). Reject if true but no evidence provided.

[DESERIALIZATION_STRATEGY]

How clients deserialize the enum: by string name, by ordinal integer, or by custom mapping

by string name - all consumers use JSON string representation; no ordinal coupling

Enum check: must be one of 'by string name', 'by ordinal integer', or 'custom mapping'. If 'custom mapping', require mapping table as additional context. Reject if strategy is ambiguous.

[ROLLBACK_PLAN]

The current rollback plan if the migration must be reversed, including rollback script availability

Rollback script exists: ALTER TYPE order_status ADD VALUE 'pending' AFTER 'draft'; tested on staging 2025-01-15

Parse check: must contain rollback steps or explicit statement that no rollback is possible. Reject if rollback plan is empty. Flag for human review if rollback involves data loss.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Enum Value Modification Impact Prompt into a CI pipeline or application for reliable, repeatable impact analysis.

The Enum Value Modification Impact Prompt is designed to be integrated into a pre-merge CI check for database migration pull requests. The core job of the harness is to gather the necessary structured context—the proposed migration SQL, the current application codebase, and the existing database schema—and feed it into the prompt in a repeatable way. The harness should not simply dump raw files into the prompt; it must pre-process the inputs to extract the specific enum definition being modified, all references to that enum in the codebase (ORM models, API serializers, client libraries, and raw SQL queries), and the current state of the data in the affected column. This targeted context assembly is critical because a generic codebase dump will exceed context windows and dilute the model's focus, leading to missed references and a false sense of security.

A concrete implementation involves a script that runs on every PR containing a *.sql or migration file with an ALTER TYPE or equivalent enum-modifying statement. The script should: (1) parse the migration to identify the target enum name and the specific change (add, remove, reorder); (2) use grep or a structural search tool like ast-grep to find all code references to that enum, including switch statements, if-else chains, and serialization annotations; (3) query the target database (or a production-like staging copy) to get a distinct count of values in the column, flagging any data that would become invalid after the change; (4) assemble these findings into the [CODE_REFERENCES], [CURRENT_DATA_PROFILE], and [PROPOSED_MIGRATION] placeholders. The harness should then call the LLM with a strict JSON output schema and validate the response. If the JSON is malformed or the severity field is missing, retry once with a repair prompt. Log the full input and output for auditability, especially for BLOCKER findings that should automatically fail the CI check and require a human override to merge.

The primary failure mode of this harness is an incomplete code reference scan. If the search tool misses a dynamic enum reference (e.g., a value constructed via string interpolation or read from a configuration file), the impact analysis will be dangerously incomplete. To mitigate this, the harness should include a secondary check: after the LLM returns its analysis, run a separate validation step that cross-references the LLM's list of identified references against a comprehensive text search for the enum values as string literals. Any string literal match not present in the LLM's analysis should be flagged as a REVIEW_REQUIRED item in the final report. Do not treat this prompt as a replacement for a staging environment migration test; it is a pre-flight risk assessment that reduces, but does not eliminate, the need for integration testing before production deployment.

IMPLEMENTATION TABLE

Expected Output Contract

The fields, types, and validation rules the output must satisfy before it can be used in a decision. Integrate these checks into your harness before the output reaches any downstream system or human reviewer.

Field or ElementType or FormatRequiredValidation Rule

impact_summary

String (1-3 sentences)

Must contain a concise statement of the overall risk level (Low/Medium/High/Critical) and the primary affected surface (application code, existing data, API clients, sort order).

affected_enum_values

Array of objects

Each object must include 'value' (string), 'action' (ADDED|REMOVED|REORDERED), and 'old_position' (integer or null). Array length must match the number of modified values in [MIGRATION_DIFF].

code_references

Array of objects

Each object must include 'file_path' (string), 'line_range' (string), 'reference_type' (DIRECT_COMPARISON|SWITCH_CASE|ORM_MAPPING|SERIALIZATION), and 'risk' (BREAKING|NEEDS_UPDATE|SAFE). If no references found, return empty array.

existing_data_compatibility

Object

Must contain 'incompatible_rows_estimate' (integer or null), 'mapping_strategy' (EXPLICIT_MAPPING|DEFAULT_VALUE|MANUAL_REQUIRED), and 'affected_tables' (array of strings). If no existing data, set incompatible_rows_estimate to 0.

sort_order_impact

Object

Must contain 'ordinal_position_changed' (boolean), 'dependent_queries_identified' (array of strings), and 'recommendation' (string). If no reordering occurred, set ordinal_position_changed to false and dependent_queries_identified to empty array.

client_deserialization_risks

Array of objects

Each object must include 'client_type' (MOBILE|WEB|THIRD_PARTY_API|INTERNAL_SERVICE), 'risk_level' (BREAKING|DEGRADED|SAFE), and 'mitigation' (string). If no API exposure, return empty array with a note in a top-level 'api_exposure_note' field.

rollback_safety

Object

Must contain 'is_rollback_safe' (boolean), 'irreversible_operations' (array of strings), and 'recommended_rollback_steps' (array of strings). If is_rollback_safe is false, irreversible_operations must be non-empty.

recommended_actions

Array of objects

Each object must include 'action' (string), 'priority' (BEFORE_MIGRATION|AFTER_MIGRATION|MONITOR), and 'owner_signal' (string indicating which team or role should own the action). Minimum 1 action required if overall risk is Medium or above.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when using an Enum Value Modification Impact Prompt in production and how to guard against it.

01

Incomplete Codebase Reference Coverage

What to watch: The prompt identifies references in ORM models and direct SQL but misses enum usage in application code, API serializers, client SDKs, or reporting queries. This creates a false sense of safety when removing or reordering values. Guardrail: Feed the prompt a pre-generated grep/ast-grep report of all enum value string occurrences across the entire repository, not just the database layer. Require the harness to scan for the enum name and each value literal before the prompt runs.

02

Sort Order and Ordinal Position Blindness

What to watch: The model correctly flags application code references but fails to analyze the impact of reordering on ORDER BY clauses, index sort order, or application-side enum.ordinal() comparisons. Reordering can silently corrupt business logic that depends on ordinal position. Guardrail: Add an explicit constraint in the prompt: 'For any reordering, list every database index, ORDER BY clause, and application ordinal comparison that depends on the current value order. Flag each as BREAKING if the order changes.'

03

Existing Data Incompatibility Oversight

What to watch: The prompt analyzes schema and code but doesn't check whether existing rows contain values that would become invalid after removal. Removing an enum value without checking production data leaves orphaned rows that cause query failures or constraint violations on next write. Guardrail: Require a pre-flight data profiling step. The harness must execute a SELECT DISTINCT on the enum column and pass the actual value distribution into the prompt context. The prompt must flag any value present in data but absent from the proposed new enum definition.

04

Client Deserialization Contract Breakage

What to watch: The prompt focuses on server-side impact but misses that mobile apps, web clients, or external API consumers may have hardcoded enum value strings or switch statements that will fail on new or removed values. Guardrail: Include an API contract context section in the prompt input. If the enum is exposed through a public or internal API, the prompt must produce a separate 'Client Impact' section listing every known consumer and whether the change is backward-compatible for each. Require human sign-off when external consumers are affected.

05

Implicit Default Value Assumptions

What to watch: When adding a new enum value, the model may not flag that existing code paths using ELSE or DEFAULT catch-alls will silently route the new value into unexpected behavior. This is especially dangerous in authorization or state machine logic. Guardrail: Add a prompt instruction: 'For every new enum value, identify all switch statements, if/else chains, and pattern matches that use a default or catch-all branch. Flag any where the new value would fall into the wrong branch.' Require a code pattern scan for default branches as harness input.

06

Migration Rollback Blindness

What to watch: The prompt produces a forward-migration impact analysis but doesn't assess whether the change is reversible. Removing an enum value is often irreversible without data restoration from backup, yet the prompt may not flag this. Guardrail: Add a mandatory output section: 'Rollback Feasibility Assessment.' The prompt must classify each change as FULLY REVERSIBLE, PARTIALLY REVERSIBLE (requires data backfill), or IRREVERSIBLE (requires backup restore). Irreversible changes must trigger a human approval gate before the migration can proceed.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of the Enum Value Modification Impact Prompt output before integrating it into your migration review workflow. Each criterion targets a specific failure mode common in enum impact analysis.

CriterionPass StandardFailure SignalTest Method

Application Code Reference Completeness

Output lists all application code files referencing the enum by name or ordinal, with line-level precision

Missing references to ORM enums, switch statements, or hardcoded integer mappings in legacy services

Run grep/static analysis across the repository for the enum name and ordinal values; diff against the prompt output

Existing Data Compatibility Assessment

Output explicitly states whether existing column values remain valid after modification, with a row count for any now-invalid values

Silent assumption that all existing rows will map cleanly; no mention of rows that would violate a new constraint

Execute a SELECT DISTINCT query on the target column; compare distinct values against the proposed new enum definition

Sort Order Change Detection

Output flags any reordering of enum values and identifies every ORDER BY clause, index, or comparison operator that depends on ordinal position

Treating enum reordering as cosmetic; no mention of index scan behavior changes or broken sort logic in API responses

Search codebase for ORDER BY, RANK, or comparison operators on the enum column; verify each is cited in the output

Client Deserialization Risk Identification

Output names every API client, mobile app version, or external integration that deserializes the enum and states the failure mode for each

Focusing only on server-side code; ignoring OpenAPI/Swagger specs, generated client libraries, or mobile app enum mappings

Audit API spec files and client SDK repositories for enum usage; confirm each consumer is listed with a specific risk statement

Serialization Format Consistency Check

Output verifies that string representations in the database match API contract values and ORM mappings exactly, including case sensitivity

Assuming string equality without checking for case mismatches, prefix/suffix differences, or legacy aliases in serialization layers

Compare enum value strings across database CHECK constraints, ORM model definitions, and API schema enums; flag any mismatch

Default Value and Fallback Handling

Output identifies every code path that uses a default enum value or fallback branch and assesses whether the default remains safe after the change

No mention of DEFAULT clauses, switch default cases, or null-coalescing fallbacks that will silently absorb the modified enum

Search for DEFAULT in schema, switch default in code, and null-coalescing operators on the enum field; verify each is analyzed

Rollback Compatibility Statement

Output includes an explicit statement on whether the migration can be rolled back without data loss or application errors

No rollback analysis, or a generic 'rollback is safe' claim without checking for irreversible enum value removal or ordinal reassignment

Simulate a rollback by reverting the enum definition and running the application test suite against a copy of production data

Downstream Reporting and Analytics Impact

Output identifies any reporting queries, materialized views, or ETL pipelines that filter or group by the enum and states the impact

Ignoring analytics and reporting systems; assuming only transactional application code matters

Search data warehouse schemas, dbt models, and BI tool definitions for references to the enum column; confirm each is addressed

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single enum change and a known codebase. Skip the full harness; paste the migration DDL, the ORM model file, and a few representative API response samples into [CONTEXT]. Ask for a plain-text impact summary instead of structured JSON.

Prompt modification

Replace [OUTPUT_SCHEMA] with: Return a bulleted list of affected files, data risks, and client impact.

Watch for

  • Missing enum references in dynamic query builders or raw SQL strings
  • Overlooking serialization libraries that map enums by ordinal position
  • No validation that the listed code paths actually reference the enum
Prasad Kumkar

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.