chore: 初始化仓库
中华文明全图鉴——文物全图系统(PC Web 地图 + NestJS API + 管理后台)。 含三大 IP(文物南迁北归 / 国宝海外回归 / 博物馆手艺人)、AI 文物对话、 文物地图与详情、以及 demo-video-kit 演示视频生成工具。
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { getPool } from "./pool";
|
||||
|
||||
export async function runSeeds(): Promise<void> {
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user