add read me
This commit is contained in:
parent
92f4ccb30a
commit
37790d56f4
3 changed files with 146 additions and 4 deletions
37
scripts/clean-migration-fk-idx.js
Normal file
37
scripts/clean-migration-fk-idx.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Script: scripts/clean-migration-fk-idx.js
|
||||
// ลบบรรทัดที่มี FK_ หรือ idx_ ในไฟล์ migration ทั้งหมด และแทนที่ด้วย comment
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const MIGRATION_DIR = path.join(__dirname, "../src/migration");
|
||||
|
||||
function processFile(filePath) {
|
||||
const lines = fs.readFileSync(filePath, "utf8").split("\n");
|
||||
let changed = false;
|
||||
const newLines = lines.map((line) => {
|
||||
if (/FK_|idx_/.test(line)) {
|
||||
changed = true;
|
||||
return " // removed FK_/idx_ auto-cleanup";
|
||||
}
|
||||
return line;
|
||||
});
|
||||
if (changed) {
|
||||
fs.writeFileSync(filePath, newLines.join("\n"), "utf8");
|
||||
console.log("Cleaned:", filePath);
|
||||
}
|
||||
}
|
||||
|
||||
function walk(dir) {
|
||||
fs.readdirSync(dir).forEach((f) => {
|
||||
const fullPath = path.join(dir, f);
|
||||
if (fs.statSync(fullPath).isDirectory()) {
|
||||
walk(fullPath);
|
||||
} else if (f.endsWith(".ts")) {
|
||||
processFile(fullPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
walk(MIGRATION_DIR);
|
||||
console.log("Migration FK_/idx_ cleanup complete.");
|
||||
Loading…
Add table
Add a link
Reference in a new issue