fix: parse SQL migration comments safely
This commit is contained in:
1 parent
8d37ae9ae0
commit
c4454a292c
3 files changed
+30
-4
No files matched your search
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user