You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/migration.ts
+13-3
Original file line number
Diff line number
Diff line change
@@ -332,10 +332,20 @@ export function parseMigrationText(
332
332
headers[key]=value ? value.trim() : value;
333
333
}
334
334
335
+
// The `\r\n` should never exist; however Windows users may be having git convert LF to CRLF, corrupting migrations.
335
336
if(strict&&lines[headerLines]!==""){
336
-
thrownewError(
337
-
`Invalid migration '${fullPath}': there should be two newlines after the headers section`,
338
-
);
337
+
if(lines[headerLines]==="\r"){
338
+
thrownewError(
339
+
`Invalid migration '${fullPath}': it looks like the line endings have been corrupted - perhaps you have configured git to replace LF with CRLF? Here's a couple potential solutions:
340
+
Option 1: Add \`path/to/migrations/committed/*.sql -text\` to \`.gitattributes\` in your repository
341
+
Option 2: Globally reconfigure git to convert CRLF to LF on commit, but never convert LF back to CRLF: \`git config --global core.autocrlf input\`
342
+
`,
343
+
);
344
+
}else{
345
+
thrownewError(
346
+
`Invalid migration '${fullPath}': there should be two newlines after the headers section`,
0 commit comments