سامانه صدور فاکتور و حسابداری
test: guard SQL migrations against literal EOF escapes
davoodmehraban89 committed
Nov 17, 2026 at 08:02 UTC
78e441a4c4d6a386302a675694141a284a3f9812
1 file changed
+23
scripts/check-migration-file-endings.mjs
new
+23
@@ -0,0 +1,23 @@
1
+import fs from 'node:fs';
2
+import path from 'node:path';
3
+
4
+const root = 'supabase/migrations';
5
+const files = fs.readdirSync(root).filter((name) => name.endsWith('.sql')).sort();
6
+const failures = [];
7
+
8
+for (const name of files) {
9
+ const file = path.join(root, name);
10
+ const content = fs.readFileSync(file, 'utf8');
11
+ if (/(?:\\\\[nrt]|\\\\)$/.test(content)) {
12
+ failures.push({ file, tail: JSON.stringify(content.slice(-40)) });
13
+ }
14
+}
15
+
16
+if (failures.length) {
17
+ for (const failure of failures) {
18
+ console.error(`INVALID_LITERAL_ESCAPE_AT_EOF ${failure.file} tail=${failure.tail}`);
19
+ }
20
+ process.exitCode = 1;
21
+} else {
22
+ console.log(`PASS: scanned ${files.length} SQL migrations; no literal escape sequences at EOF.`);
23
+}