MCPcopy Index your code
hub / github.com/simstudioai/sim / main

Function main

scripts/check-migrations-safety.ts:450–489  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

448}
449
450async function main() {
451 const files = await resolveFiles(process.argv.slice(2))
452 if (files === null) process.exit(0)
453
454 if (files.length === 0) {
455 console.log('✓ No new migrations to check.')
456 process.exit(0)
457 }
458
459 let errors = 0
460 let warnings = 0
461 for (const rel of files) {
462 const content = await readFile(path.join(ROOT, rel), 'utf8')
463 const findings = lintSql(content)
464 if (findings.length === 0) continue
465
466 console.error(`\n${rel}`)
467 for (const f of findings.sort((a, b) => a.line - b.line)) {
468 const icon = f.tier === 'error' ? '✗' : '⚠'
469 if (f.tier === 'error') errors++
470 else warnings++
471 console.error(` ${icon} ${rel}:${f.line} [${f.rule}]`)
472 console.error(` ${f.statement.replace(/\s+/g, ' ').slice(0, 120)}`)
473 console.error(` → ${f.message}`)
474 }
475 }
476
477 if (errors === 0) {
478 console.log(
479 warnings > 0
480 ? `\n✓ No blocking migration issues (${warnings} warning(s) to review).`
481 : '\n✓ Migrations are backward-compatible.'
482 )
483 process.exit(0)
484 }
485 console.error(
486 `\nFound ${errors} blocking migration issue(s). Rewrite hard errors into expand/contract, or annotate contract ops once safe. See the /db-migrate skill.`
487 )
488 process.exit(1)
489}
490
491if (import.meta.main) main()

Callers 1

Calls 7

resolveFilesFunction · 0.85
readFileFunction · 0.85
lintSqlFunction · 0.85
logMethod · 0.80
joinMethod · 0.80
errorMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected