mcp-migration-advisor 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,6 +74,11 @@ export function analyzeDataLoss(migration) {
74
74
  break;
75
75
  }
76
76
  case "OTHER": {
77
+ // CREATE FUNCTION/PROCEDURE/TRIGGER bodies may contain TRUNCATE/DELETE/UPDATE
78
+ // statements that only execute when the function is invoked — not at migration time.
79
+ // Skip data manipulation checks for CREATE statements to avoid false positives.
80
+ if (/^CREATE\b/i.test(stmt.raw.trim()))
81
+ break;
77
82
  // Detect TRUNCATE
78
83
  if (upper.includes("TRUNCATE")) {
79
84
  const tableMatch = stmt.raw.match(/TRUNCATE\s+(?:TABLE\s+)?(?:`|"|)?(?:\w+\.)?(\w+)/i);
@@ -66,13 +66,17 @@ function generateRollbackStatement(stmt) {
66
66
  isReversible: true,
67
67
  warning: null,
68
68
  };
69
- case "DROP_TABLE":
69
+ case "DROP_TABLE": {
70
+ const hasCascade = stmt.details.cascade === "true";
70
71
  return {
71
72
  forward: stmt.raw,
72
73
  rollback: `-- Cannot reverse DROP TABLE ${stmt.tableName} without schema backup`,
73
74
  isReversible: false,
74
- warning: `DROP TABLE ${stmt.tableName} is irreversible — table structure and data are lost. Restore from backup.`,
75
+ warning: hasCascade
76
+ ? `DROP TABLE ${stmt.tableName} CASCADE is irreversible — table and all dependent objects (views, foreign keys, indexes) are permanently destroyed. Each dependent object must be recreated manually.`
77
+ : `DROP TABLE ${stmt.tableName} is irreversible — table structure and data are lost. Restore from backup.`,
75
78
  };
79
+ }
76
80
  case "CREATE_INDEX": {
77
81
  // Extract index name from the raw SQL
78
82
  const indexMatch = stmt.raw.match(/INDEX\s+(?:CONCURRENTLY\s+)?(?:IF\s+NOT\s+EXISTS\s+)?(?:`|"|)?(\w+)/i);
package/build/index.js CHANGED
@@ -33,7 +33,7 @@ function formatParserWarnings(migration) {
33
33
  }
34
34
  // Handle --help
35
35
  if (process.argv.includes("--help") || process.argv.includes("-h")) {
36
- console.log(`mcp-migration-advisor v0.2.6 — MCP server for database migration risk analysis
36
+ console.log(`mcp-migration-advisor v0.2.9 — MCP server for database migration risk analysis
37
37
 
38
38
  Usage:
39
39
  mcp-migration-advisor [options]
@@ -52,7 +52,7 @@ Tools provided:
52
52
  }
53
53
  const server = new McpServer({
54
54
  name: "mcp-migration-advisor",
55
- version: "0.2.6",
55
+ version: "0.2.9",
56
56
  });
57
57
  // Tool 1: analyze_migration
58
58
  server.tool("analyze_migration", "Analyze a SQL migration file for lock risks, data loss potential, and unsafe patterns. Supports Flyway (V__*.sql) and plain SQL.", {
@@ -62,7 +62,11 @@ server.tool("analyze_migration", "Analyze a SQL migration file for lock risks, d
62
62
  const migration = parseMigration(filename, sql);
63
63
  const lockRisks = analyzeLockRisks(migration);
64
64
  const dataLossIssues = analyzeDataLoss(migration);
65
- const riskScore = calculateRiskScore(lockRisks);
65
+ const lockScore = calculateRiskScore(lockRisks);
66
+ const dataLossScore = Math.min(100, dataLossIssues.filter(i => i.risk === "CERTAIN").length * 25 +
67
+ dataLossIssues.filter(i => i.risk === "LIKELY").length * 15 +
68
+ dataLossIssues.filter(i => i.risk === "POSSIBLE").length * 5);
69
+ const riskScore = Math.min(100, lockScore + dataLossScore);
66
70
  let output = `## Migration Analysis: ${filename}\n\n`;
67
71
  // Migration info
68
72
  if (migration.version) {
@@ -112,7 +116,7 @@ server.tool("analyze_migration", "Analyze a SQL migration file for lock risks, d
112
116
  };
113
117
  });
114
118
  // Tool 2: analyze_liquibase
115
- server.tool("analyze_liquibase", "Analyze a Liquibase XML changelog for lock risks, data loss potential, and unsafe patterns.", {
119
+ server.tool("analyze_liquibase", "Analyze a Liquibase XML changelog for lock risks, data loss potential, and unsafe patterns. Supports createTable, dropTable, addColumn, dropColumn, modifyDataType, createIndex, addForeignKeyConstraint, renameTable, renameColumn, and more.", {
116
120
  xml: z.string().describe("The Liquibase XML changelog content"),
117
121
  }, async ({ xml }) => {
118
122
  const migration = parseLiquibaseXml(xml);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-migration-advisor",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "MCP server for database migration risk analysis — Flyway and Liquibase XML/YAML/SQL support with lock detection and conflict analysis",
5
5
  "mcpName": "io.github.dmitriusan/mcp-migration-advisor",
6
6
  "main": "build/index.js",
@@ -40,7 +40,7 @@
40
40
  "author": "Dmytro Lisnichenko",
41
41
  "license": "MIT",
42
42
  "engines": {
43
- "node": ">=18.0.0"
43
+ "node": ">=20.0.0"
44
44
  },
45
45
  "repository": {
46
46
  "type": "git",
@@ -52,11 +52,11 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@modelcontextprotocol/sdk": "^1.27.1",
55
- "zod": "^3.24.2"
55
+ "zod": "^4.0.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@types/node": "^22.0.0",
59
- "typescript": "^5.8.2",
60
- "vitest": "^4.0.18"
58
+ "@types/node": "^25.5.0",
59
+ "typescript": "^6.0.0",
60
+ "vitest": "^4.1.0"
61
61
  }
62
62
  }