mcp-migration-advisor 0.2.3 → 0.2.4

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.
@@ -147,6 +147,17 @@ function analyzeStatement(stmt) {
147
147
  recommendation: "Avoid explicit locks in migrations. Use row-level locking or redesign the migration.",
148
148
  });
149
149
  }
150
+ // TRUNCATE acquires ACCESS EXCLUSIVE lock — same severity as DROP TABLE
151
+ if (stmt.type === "OTHER" && /\bTRUNCATE\b/i.test(stmt.raw)) {
152
+ const tableMatch = stmt.raw.match(/TRUNCATE\s+(?:TABLE\s+)?(?:`|"|)?(\w+)/i);
153
+ risks.push({
154
+ severity: "HIGH",
155
+ statement: truncate(stmt.raw),
156
+ tableName: tableMatch?.[1] || null,
157
+ risk: "TRUNCATE acquires ACCESS EXCLUSIVE lock, blocking all concurrent reads and writes for the duration.",
158
+ recommendation: "On large tables, prefer DELETE with a WHERE clause in batches. If speed is critical, ensure a maintenance window.",
159
+ });
160
+ }
150
161
  return risks;
151
162
  }
152
163
  function truncate(s, max = 120) {
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.1.0 — MCP server for database migration risk analysis
36
+ console.log(`mcp-migration-advisor v0.2.4 — 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.1.0",
55
+ version: "0.2.4",
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.", {
@@ -31,7 +31,8 @@ export function parseFlywayFilename(filename) {
31
31
  }
32
32
  /**
33
33
  * Split SQL text into individual statements.
34
- * Handles semicolons, ignoring those inside strings and comments.
34
+ * Handles semicolons, ignoring those inside string literals and comments.
35
+ * Single-quoted strings are tracked; escaped quotes ('') are handled correctly.
35
36
  */
36
37
  function splitStatements(sql) {
37
38
  // Remove block comments
@@ -40,16 +41,38 @@ function splitStatements(sql) {
40
41
  cleaned = cleaned.replace(/--.*$/gm, "");
41
42
  const stmts = [];
42
43
  let current = "";
43
- for (const char of cleaned) {
44
- if (char === ";") {
44
+ let inString = false;
45
+ let i = 0;
46
+ while (i < cleaned.length) {
47
+ const char = cleaned[i];
48
+ if (char === "'" && !inString) {
49
+ inString = true;
50
+ current += char;
51
+ i++;
52
+ }
53
+ else if (char === "'" && inString) {
54
+ current += char;
55
+ i++;
56
+ // '' is the SQL escape for a literal single quote inside a string
57
+ if (i < cleaned.length && cleaned[i] === "'") {
58
+ current += cleaned[i];
59
+ i++;
60
+ }
61
+ else {
62
+ inString = false;
63
+ }
64
+ }
65
+ else if (char === ";" && !inString) {
45
66
  const trimmed = current.trim();
46
67
  if (trimmed.length > 0) {
47
68
  stmts.push(trimmed);
48
69
  }
49
70
  current = "";
71
+ i++;
50
72
  }
51
73
  else {
52
74
  current += char;
75
+ i++;
53
76
  }
54
77
  }
55
78
  const last = current.trim();
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "mcp-migration-advisor",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "MCP server for database migration risk analysis — Flyway and Liquibase XML/YAML/SQL support with lock detection and conflict analysis",
5
+ "mcpName": "Migration Advisor",
5
6
  "main": "build/index.js",
6
7
  "bin": {
7
8
  "mcp-migration-advisor": "build/index.js"