Auto-Rollback Generation
Derives inverse SQL from a forward migration and enumerates operations that cannot be reversed rather than fabricating a fake rollback.
Reversibility rules
DROP TABLE, recoverable only if the original CREATE is present in the script; otherwise irreversible.DELETEwithout backup, irreversible.TRUNCATE, irreversible.ADD COLUMN↔DROP COLUMN, reversible forward, irreversible back (data is lost).CREATE INDEX↔DROP INDEX, reversible.ALTER COLUMNtype change, inverse attempted, with a warning when the original type would lose data.
Output
{
rollbackSql: 'SQL that reverses the forward script',
irreversible: ['operation 1 that cannot be reversed'...],
notes: 'explanation of choices and caveats'
}
The agent is constrained to never invent DDL for tables/columns the forward script doesn't reference.