sendou.ink/scripts/refresh-prod-db.ts
Kalle dd1adad94b
Some checks are pending
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
BIome v2 upgrade
2025-06-22 16:49:27 +03:00

41 lines
1.1 KiB
TypeScript

/** biome-ignore-all lint/suspicious/noConsole: Biome v2 migration */
import fs from "node:fs";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import path from "node:path";
function main() {
const dbProdPath = path.join(__dirname, "..", "db-prod.sqlite3");
const dbProdShmPath = path.join(__dirname, "..", "db-prod.sqlite3-shm");
const dbProdWalPath = path.join(__dirname, "..", "db-prod.sqlite3-wal");
const dbCopyPath = path.join(__dirname, "..", "db-copy.sqlite3");
if (!fs.existsSync(dbCopyPath)) {
console.error(`File ${dbCopyPath} does not exist`);
process.exit(1);
}
// delete db-prod.sqlite3-shm file if exists
if (fs.existsSync(dbProdShmPath)) {
fs.unlinkSync(dbProdShmPath);
}
// delete db-prod.sqlite3-wal file if exists
if (fs.existsSync(dbProdWalPath)) {
fs.unlinkSync(dbProdWalPath);
}
// delete db-prod.sqlite3 if exists
if (fs.existsSync(dbProdPath)) {
fs.unlinkSync(dbProdPath);
}
// copy db-copy.sqlite3 to db-prod.sqlite3
fs.copyFileSync(dbCopyPath, dbProdPath);
}
main();