mcp-migration-advisor 0.2.6 → 0.2.8

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);
@@ -132,6 +132,22 @@ function generateRollbackStatement(stmt) {
132
132
  warning: `Type change on ${stmt.tableName}.${stmt.columnName} requires knowing the original type. Check schema before migration.`,
133
133
  };
134
134
  }
135
+ if (stmt.details.setDefault === "true") {
136
+ return {
137
+ forward: stmt.raw,
138
+ rollback: `ALTER TABLE ${stmt.tableName} ALTER COLUMN ${stmt.columnName} DROP DEFAULT`,
139
+ isReversible: true,
140
+ warning: null,
141
+ };
142
+ }
143
+ if (stmt.details.dropDefault === "true") {
144
+ return {
145
+ forward: stmt.raw,
146
+ rollback: `-- Cannot reverse DROP DEFAULT on ${stmt.tableName}.${stmt.columnName} — original default value unknown`,
147
+ isReversible: false,
148
+ warning: `DROP DEFAULT on ${stmt.tableName}.${stmt.columnName} requires knowing the original default value to reverse.`,
149
+ };
150
+ }
135
151
  return {
136
152
  forward: stmt.raw,
137
153
  rollback: `-- Cannot reverse: ${stmt.raw.slice(0, 80)}`,
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.5 — MCP server for database migration risk analysis
36
+ console.log(`mcp-migration-advisor v0.2.8 — 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.5",
55
+ version: "0.2.8",
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.", {
@@ -112,7 +112,7 @@ server.tool("analyze_migration", "Analyze a SQL migration file for lock risks, d
112
112
  };
113
113
  });
114
114
  // Tool 2: analyze_liquibase
115
- server.tool("analyze_liquibase", "Analyze a Liquibase XML changelog for lock risks, data loss potential, and unsafe patterns.", {
115
+ 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
116
  xml: z.string().describe("The Liquibase XML changelog content"),
117
117
  }, async ({ xml }) => {
118
118
  const migration = parseLiquibaseXml(xml);
@@ -200,6 +200,8 @@ server.tool("score_risk", "Calculate the combined risk score (0-100) for a SQL m
200
200
  const riskScore = calculateRiskScore(lockRisks);
201
201
  const criticalCount = lockRisks.filter(r => r.severity === "CRITICAL").length;
202
202
  const highCount = lockRisks.filter(r => r.severity === "HIGH").length;
203
+ const mediumCount = lockRisks.filter(r => r.severity === "MEDIUM").length;
204
+ const lowCount = lockRisks.filter(r => r.severity === "LOW").length;
203
205
  const dataLossCertain = dataLossIssues.filter(i => i.risk === "CERTAIN").length;
204
206
  const dataLossLikely = dataLossIssues.filter(i => i.risk === "LIKELY").length;
205
207
  const dataLossPossible = dataLossIssues.filter(i => i.risk === "POSSIBLE").length;
@@ -226,6 +228,8 @@ server.tool("score_risk", "Calculate the combined risk score (0-100) for a SQL m
226
228
  |----------|-------|--------------------|
227
229
  | CRITICAL lock risks | ${criticalCount} | ${criticalCount * 30} |
228
230
  | HIGH lock risks | ${highCount} | ${highCount * 20} |
231
+ | MEDIUM lock risks | ${mediumCount} | ${mediumCount * 10} |
232
+ | LOW lock risks | ${lowCount} | ${lowCount * 5} |
229
233
  | Certain data loss | ${dataLossCertain} | ${dataLossCertain * 25} |
230
234
  | Likely data loss | ${dataLossLikely} | ${dataLossLikely * 15} |
231
235
  | Possible data loss | ${dataLossPossible} | ${dataLossPossible * 5} |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-migration-advisor",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
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
  }