import * as fs from "fs"; import * as path from "path"; import { getPool } from "./pool"; export async function runSeeds(): Promise { const pool = getPool(); const seedsDir = path.resolve(__dirname, "../seeds"); const files = fs .readdirSync(seedsDir) .filter((f) => f.endsWith(".sql")) .sort(); for (const file of files) { const sql = fs.readFileSync(path.join(seedsDir, file), "utf-8"); console.log(`[seed] apply ${file}`); await pool.query(sql); console.log(`[seed] done ${file}`); } console.log("[seed] all seeds complete"); await pool.end(); }