Skip to main content

format_as_sql

Function format_as_sql 

Source
pub fn format_as_sql(diff: &SchemaDiff) -> String
Expand description

Format a SchemaDiff as a copy-paste-friendly SQL string.

Layout:

-- EXPLAIN ALTER FOR <table>
-- N changes detected (A adds, D drops, T type changes)
-- rename candidates: R
ALTER TABLE <table> ADD COLUMN <col> <type>;
ALTER TABLE <table> DROP COLUMN <col>;
-- hint: `from` -> `to` could be a rename (confidence: ..., basis: ...)

When the diff is empty (“no drift”), the function returns just the -- header so clients can grep for “0 changes”.