fix: parse SQL migration comments safely

This commit is contained in:
simoleo89
2026-07-11 21:27:18 +02:00
parent 8d37ae9ae0
commit c4454a292c
3 changed files with 30 additions and 4 deletions
+10
View File
@@ -0,0 +1,10 @@
export function splitSqlStatements(sql: string): string[] {
const withoutComments = sql
.replace(/\/\*[\s\S]*?\*\//g, "")
.replace(/^\s*--.*$/gm, "");
return withoutComments
.split(";")
.map((statement) => statement.trim())
.filter(Boolean);
}