fix: parse SQL migration comments safely

This commit is contained in:
Simo committed 2026-07-11 21:27:18 +02:00
1 parent 8d37ae9ae0
commit c4454a292c
3 files changed
+30 -4

No files matched your search

+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);
}