Files
bun-sqlite/dist/lib/schema/record-schema-change.js
T

20 lines
684 B
JavaScript

/**
* # Record a schema change before it runs
* @description Logs the change (unless this is a dry run) and refuses
* destructive changes that were not approved.
*/
export default function recordSchemaChange(params, change) {
params.changes?.push(change);
if (params.dry_run) {
return;
}
const allowed = params.allow_destructive;
if (change.destructive &&
allowed !== undefined &&
allowed !== true &&
!allowed.has(change.description)) {
throw new Error(`Refusing unapproved destructive change: ${change.description}. Re-run with --dry-run to review, or --yes to allow it.`);
}
console.log(change.description);
}