Install
openclaw skills install migratesafeDatabase migration safety checker — catches destructive migrations before they reach production
openclaw skills install migratesafeMigrateSafe analyzes database migration files for destructive operations before they reach production. It detects DROP TABLE, column removals, risky type changes, missing rollbacks, lock hazards, and unsafe ALTER operations across raw SQL, Rails, Django, Knex.js, Prisma, Flyway, and Liquibase migrations. It uses regex-based pattern matching with risk scoring and produces compliance reports.
migratesafe scan [file|directory]One-shot scan of migration files for destructive operations.
How to execute:
bash "<SKILL_DIR>/scripts/migratesafe.sh" scan [target]
What it does:
Example usage scenarios:
migratesafe scan .migratesafe scan db/migrate/20240115_add_users.sqlmigratesafe scan migrations/migratesafe helpShow available commands and usage information.
bash "<SKILL_DIR>/scripts/migratesafe.sh" help
migratesafe versionShow version information.
bash "<SKILL_DIR>/scripts/migratesafe.sh" version
migratesafe hooks installInstall git pre-commit hooks that scan staged migration files before every commit.
How to execute:
bash "<SKILL_DIR>/scripts/migratesafe.sh" hooks install
What it does:
migratesafe hooks uninstallRemove MigrateSafe git hooks.
bash "<SKILL_DIR>/scripts/migratesafe.sh" hooks uninstall
migratesafe rollback-check [directory]Verify that every UP migration has a corresponding DOWN/rollback migration.
bash "<SKILL_DIR>/scripts/migratesafe.sh" rollback-check [directory]
What it does:
migratesafe diff <file1> <file2>Compare two schema versions and highlight dangerous changes.
bash "<SKILL_DIR>/scripts/migratesafe.sh" diff schema_v1.sql schema_v2.sql
What it does:
migratesafe history [directory]Show migration risk history across all migrations in the project.
bash "<SKILL_DIR>/scripts/migratesafe.sh" history [directory]
What it does:
migratesafe report [directory]Generate a full compliance report in markdown format.
bash "<SKILL_DIR>/scripts/migratesafe.sh" report [directory]
What it does:
MigrateSafe detects 15+ destructive patterns across 7 migration frameworks:
| Category | Examples | Severity |
|---|---|---|
| Table Drops | DROP TABLE, drop_table, DeleteModel, dropTable | Critical |
| Truncation | TRUNCATE TABLE, unconditional DELETE FROM | Critical |
| Column Drops | DROP COLUMN, remove_column, RemoveField, dropColumn | High |
| Type Changes | ALTER COLUMN...TYPE, change_column, AlterField | High |
| Constraint Removal | DROP CONSTRAINT, DROP INDEX, RemoveConstraint, remove_index | High |
| NOT NULL Additions | SET NOT NULL (without DEFAULT), add non-null column | Medium |
| Missing Transactions | Migrations not wrapped in BEGIN/COMMIT | Medium |
| Lock Hazards | CREATE INDEX (without CONCURRENTLY), ALTER TABLE on large tables | Medium |
| Cascade Deletes | ON DELETE CASCADE, CASCADE changes | Medium |
| Column Renames | RENAME COLUMN, rename_column, RenameField | Low |
| Data Loss Risk | REPLACE operations, ON DELETE SET NULL changes | Low |
| Framework | File Pattern | Detection |
|---|---|---|
| Raw SQL | *.sql | Full SQL pattern matching |
| Rails | db/migrate/*.rb | remove_column, drop_table, change_column, etc. |
| Django | migrations/*.py | RemoveField, DeleteModel, AlterField, etc. |
| Knex.js | migrations/.js/.ts | dropTable, dropColumn, raw.*DROP, etc. |
| Prisma | prisma/migrations/*.sql | Full SQL pattern matching |
| Flyway | sql/V*.sql | Full SQL pattern matching |
| Liquibase | *.xml changesets | dropTable, dropColumn, modifyDataType, etc. |
Add to ~/.openclaw/openclaw.json:
{
"skills": {
"entries": {
"migratesafe": {
"enabled": true,
"apiKey": "YOUR_LICENSE_KEY",
"config": {
"severityThreshold": "high",
"migrationDirs": ["db/migrate", "migrations", "prisma/migrations", "sql"],
"ignorePatterns": ["**/test/**", "**/seed/**"],
"requireRollbacks": true,
"blockOnCritical": true
}
}
}
}
}
hooks install, prompt to install itThe user might say things like:
brew install lefthook