Skip to content

Analyze Migration

POST
/api/v1/connections/{connection_id}/migrations/analyze

Analyze a SQL migration and return a unified response.

Parses the SQL, validates against the schema, identifies blast radius, scores risk, generates rollback DDL, runs sandbox validation, and returns an HMAC-signed approval token for execution. By default, enriches the report with an AI-powered business narrative and impact chains. Use ?enrich=false to skip enrichment.

connection_id
required
Connection Id
string format: uuid
enrich
Enrich

Set to false to skip AI enrichment

boolean
default: true

Set to false to skip AI enrichment

sandbox
Sandbox
boolean
MigrationAnalysisRequest
object
sql
required
Sql

Raw SQL DDL migration text. Can contain multiple statements separated by semicolons.

string
>= 1 characters

Successful Response

AnalyzeResultResponse

Response for POST /migrations/analyze (full analysis with enrichment).

object
success
required
Success

Whether the request succeeded.

boolean
data
Any of:
AnalyzeResponse

Full analysis response with sandbox results and approval token.

object
connection_id
required
Connection Id

ID of the database connection the migration was analyzed against.

string format: uuid
total_statements
required
Total Statements

Number of SQL statements in the migration.

integer
risk_score
required
Risk Score

Aggregate risk score from 0-100 across all statements. Uses the maximum individual statement score for conservative reporting.

integer
risk_category
required
Risk Category

Aggregate risk classification. ‘low’ (0-25) = schema-only changes, ‘medium’ (26-50) = data modifications, ‘high’ (51-75) = locking operations, ‘critical’ (76-100) = destructive or high-impact changes.

string
statements
required
Statements

Per-statement breakdown of the migration. Each entry analyzes one SQL statement’s risk, affected tables, and rollback steps.

Array<object>
StatementAnalysis
object
index
required
Index

Zero-based position of this statement in the migration.

integer
sql
required
Sql

The SQL DDL statement being analyzed.

string
statement_type
required
Statement Type

Type of DDL operation. Examples: ‘ALTER TABLE’, ‘CREATE TABLE’, ‘DROP TABLE’, ‘CREATE INDEX’.

string
table
Any of:
string
column_names
Column Names

Column names explicitly referenced in this statement. Empty for table-level operations (CREATE TABLE, DROP TABLE). Populated for ALTER TABLE column operations.

Array<string>
default:
lock_type
Any of:
string
lock_duration_ms
Any of:
integer
risk_score
required
Risk Score

Risk score from 0-100 for this individual statement. Factors: lock severity, FK cascades, destructive potential, index complexity.

integer
risk_category
required
Risk Category

Risk classification derived from score. ‘low’ (0-25) = schema-only changes, ‘medium’ (26-50) = data modifications, ‘high’ (51-75) = locking operations, ‘critical’ (76-100) = destructive or high-impact changes.

string
affected_tables
required
Affected Tables

Tables affected by this statement, including FK cascade targets.

Array<object>
AffectedTable
object
table
required
Table

Name of the database table affected by this migration statement.

string
impact
required
Impact

How this table is affected. ‘direct’ means the statement explicitly modifies it; ‘cascade’ means it is impacted through foreign key relationships.

string
cascade_path
Any of:
Array<string>
affected_columns
Affected Columns

Columns in this table affected by the statement. Empty list means all columns are affected (table-level operation like DROP TABLE or CREATE TABLE).

Array<string>
default:
rollback
required
RollbackStep

Rollback step to reverse this specific statement.

object
statement_index
required
Statement Index

Zero-based index of the original migration statement this rollback reverses.

integer
sql
Any of:
string
reversible
required
Reversible

Whether this migration statement can be automatically reversed.

boolean
warning
Any of:
string
warnings
Warnings

List of warning messages about potential risks or side effects.

Array<string>
default:
affected_tables
required
Affected Tables

Deduplicated list of all tables affected across all statements, including FK cascade targets.

Array<object>
AffectedTable
object
table
required
Table

Name of the database table affected by this migration statement.

string
impact
required
Impact

How this table is affected. ‘direct’ means the statement explicitly modifies it; ‘cascade’ means it is impacted through foreign key relationships.

string
cascade_path
Any of:
Array<string>
affected_columns
Affected Columns

Columns in this table affected by the statement. Empty list means all columns are affected (table-level operation like DROP TABLE or CREATE TABLE).

Array<string>
default:
rollback_plan
required
RollbackPlan

Complete rollback plan with transaction-wrapped script to reverse the entire migration.

object
steps
required
Steps

Ordered list of rollback steps, one per original migration statement.

Array<object>
RollbackStep
object
statement_index
required
Statement Index

Zero-based index of the original migration statement this rollback reverses.

integer
sql
Any of:
string
reversible
required
Reversible

Whether this migration statement can be automatically reversed.

boolean
warning
Any of:
string
combined_script
Any of:
string
has_irreversible
required
Has Irreversible

True if any migration statement cannot be automatically reversed.

boolean
warnings
Warnings

Aggregate warning messages across all statements.

Array<string>
default:
business_narrative
Any of:
BusinessNarrative
object
summary
required
Summary

Plain-language explanation of the migration’s risk and business impact, generated by the AI narrative engine.

string
affected_processes
required
Affected Processes

Business processes that may be impacted by the migration, inferred from document context and schema relationships.

Array<string>
citations
required
Citations

References to uploaded documents that informed the narrative. Empty when no relevant documents exist.

Array<object>
Citation
object
document_filename
required
Document Filename

Name of the source document this citation references.

string
excerpt
required
Excerpt

Relevant text excerpt from the document.

string
relevance
required
Relevance

Brief explanation of why this document is relevant to the migration analysis.

string
schema_only
required
Schema Only

True when no RAG documents were available and the narrative was generated from schema metadata alone.

boolean
impact_chains
Impact Chains

Tree of cascading impacts starting from directly affected tables, through FK cascades, views, and RAG-inferred dependencies.

Array<object>
default:
ImpactNode
object
name
required
Name

Name of the impacted entity (table, view, or inferred report).

string
node_type
required
Node Type

Type of entity. ‘table’ for database tables, ‘view’ for database views, ‘report’ for RAG-inferred business reports.

string
relationship
required
Relationship

How this entity is connected to the migration. ‘direct’ = explicitly modified, ‘fk_cascade’ = affected via foreign key, ‘view_reference’ = depends via view definition, ‘rag_inferred’ = inferred from document context.

string
children
Array<object> recursive
sandbox_result
Any of:
SandboxResult
object
passed
required
Passed

Whether the migration applied successfully and all validation queries passed.

boolean
migration_applied
required
Migration Applied

Whether the migration SQL was successfully executed against the sandbox schema.

boolean
migration_error
Any of:
string
tables_created
required
Tables Created

Number of tables created in the sandbox from the schema snapshot.

integer
rows_inserted
required
Rows Inserted

Total number of synthetic data rows inserted across all tables.

integer
validation_results
required
Validation Results

Results of each validation query run against the post-migration sandbox.

Array<object>
ValidationQueryResult
object
query
required
Query

The SQL validation query that was executed.

string
passed
required
Passed

Whether the validation query completed without errors.

boolean
error
Any of:
string
duration_ms
required
Duration Ms

Execution time of the validation query in milliseconds.

integer
duration_ms
required
Duration Ms

Total sandbox execution time in milliseconds, including schema setup, data generation, migration, and validation.

integer
approval_token
Any of:
string
non_transactional_statements
Non Transactional Statements

Zero-based indices of statements that cannot run inside a transaction (e.g., CREATE INDEX CONCURRENTLY). These are executed with AUTOCOMMIT isolation.

Array<integer>
default:
error
Any of:
ErrorDetail
object
code
required
Code

Machine-readable error code (e.g., ‘NOT_FOUND’, ‘VALIDATION_ERROR’).

string
message
required
Message

Human-readable error message describing what went wrong.

string
details
Any of:

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object