This commit is contained in:
seb
2026-07-31 09:00:14 +02:00
parent 4f98082061
commit 99dd76075e
24 changed files with 1477 additions and 1175 deletions

View File

@@ -88,6 +88,22 @@ function parseSchema(source) {
});
}
const alterAddColumnRegex =
/ALTER TABLE\s+(\w+)\s+ADD\s+(\w+)\s+([\w]+(?:\([^)]*\))?)(?:\s+(NOT NULL|NULL))?\s*;/gi;
let alterColumnMatch;
while ((alterColumnMatch = alterAddColumnRegex.exec(sqlBlock)) !== null) {
const tableName = alterColumnMatch[1];
const name = alterColumnMatch[2];
const type = alterColumnMatch[3];
const nullable = alterColumnMatch[4]?.toUpperCase() !== 'NOT NULL';
const table = tables.get(tableName);
if (!table || table.columns.some((c) => c.name === name)) continue;
table.columns.push({ name, type, nullable, isPk: false });
}
const alterFkRegex =
/ALTER TABLE\s+(\w+)\s+ADD CONSTRAINT\s+(\w+)\s+FOREIGN KEY\s*\(([^)]+)\)\s+REFERENCES\s+(\w+)\(([^)]+)\)(?:\s+ON DELETE\s+([\w\s]+?))?\s*;/gi;
let alterMatch;