Data cleaning
AuraScore 85/100

Relational Schema Migration Data Scrubbing Specification

Specify database data cleansing rules to resolve orphan records, encoding corruptions, and invalid types before a major schema migration.

Use this template when planning zero-downtime database migrations that require pre-migration data sanitation. It establishes concrete remediation logic for legacy schema anomalies, type mismatches, and orphan foreign keys.

Template

Role: Staff Database Reliability Engineer with 14 years of experience executing zero-downtime database migrations and data hygiene protocols.

Context

  • Source Entity: {{legacy_table_name}}
  • Target Database Engine: {{target_schema_dialect}}
  • Null Value Strategy: {{null_handling_strategy}}
  • Text Encoding Baseline: {{encoding_standards}}
  • Error Tolerance: {{validation_error_threshold}}
  • Migration Chunking: {{migration_batch_size}}

Task

Produce an executable data cleansing specification to remediate corrupted, truncated, or invalid records in {{legacy_table_name}} before migrating into {{target_schema_dialect}}.

Method

  1. Audit {{legacy_table_name}} for invalid byte sequences and formulate transcode routines to match {{encoding_standards}}.
  2. Specify cleansing rules for orphan foreign keys that violate relational integrity in {{target_schema_dialect}}.
  3. Apply {{null_handling_strategy}} across nullable legacy columns converting to NOT NULL constraints.
  4. Design data type coercion logic for misformatted dates, boolean integers, and untyped string blobs.
  5. Establish automated trimming rules for whitespace, non-printable control characters, and rogue trailing escapes.
  6. Formulate deterministic deduplication algorithms for rows with colliding natural keys.
  7. Construct staging validation gates enforcing the {{validation_error_threshold}}.
  8. Define rollback checkpoints and dry-run assertions for each {{migration_batch_size}} chunk.

Constraints

  • MUST NOT mutate immutable audit timestamps or primary key sequences.
  • Cleansing scripts MUST be idempotent and safe to re-run over interrupted batches.
  • Data mutations must be recorded in an audit table with before-and-after values.
  • Total unrecoverable record drops MUST NOT exceed {{validation_error_threshold}}.

Output format

Deliver the technical specification in three sections:

  1. Data Anomaly Remediation Logic (table: Anomaly Type, Detection SQL/Regex, Scrubbing Operation)
  2. Batch Execution & Validation Protocol (step-by-step for {{migration_batch_size}})
  3. Rollback & Quarantine Policy (numbered list) Total length must not exceed 800 words.

Self-review

  • Ensure {{null_handling_strategy}} explicitly handles default value assignments.
  • Check that all character encoding edge cases conform to {{encoding_standards}}.
  • Confirm that batch boundaries prevent database lock escalation.
AuraScore breakdown
85/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

data-analytics
data-cleaning
software-engineering-debugging
database
sql
migration