Skip to content

Commit e006a69

Browse files
authored
Merge pull request #99 from smallerqiu/main
fix: install sql path
2 parents 2ce521d + 39a43b1 commit e006a69

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/install.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Client } from 'pg';
22
import fs from 'fs';
33
import config from './config';
4+
import path from 'path';
45

56
export default async function () {
67
if (!config.pgsql.host || !config.pgsql.database) {
@@ -31,7 +32,8 @@ export default async function () {
3132
console.log("[init] Tables created, skip installation.");
3233
} else {
3334
console.log("[init] Tables not exists, installing...");
34-
const sqlCreate = fs.readFileSync("./scripts/create.sql", "utf8");
35+
const sqlPath = path.join(__dirname, "./scripts/create.sql");
36+
const sqlCreate = fs.readFileSync(sqlPath, "utf8");
3537
await client.query(sqlCreate);
3638
console.log("[init] Created successfully.");
3739
}
@@ -46,7 +48,8 @@ export default async function () {
4648
console.log("[v0.0.5] Tables created, skip installation.");
4749
} else {
4850
console.log("[v0.0.5] Tables not exists, installing...");
49-
const sqlCreate_0_0_5 = fs.readFileSync("./scripts/patch-0.0.5.sql", "utf8");
51+
const sqlPath = path.join(__dirname, "./scripts/patch-0.0.5.sql");
52+
const sqlCreate_0_0_5 = fs.readFileSync(sqlPath, "utf8");
5053
await client.query(sqlCreate_0_0_5);
5154
console.log("[v0.0.5] Created successfully.");
5255
}
@@ -60,7 +63,8 @@ export default async function () {
6063
console.log("[v0.0.12] Tables created, skip installation.");
6164
} else {
6265
console.log("[v0.0.12] Tables not exists, installing...");
63-
const sqlCreate_0_0_12 = fs.readFileSync("./scripts/patch-0.0.12.sql", "utf8");
66+
const sqlPath = path.join(__dirname, "./scripts/patch-0.0.12.sql");
67+
const sqlCreate_0_0_12 = fs.readFileSync(sqlPath, "utf8");
6468
await client.query(sqlCreate_0_0_12);
6569
console.log("[v0.0.12] Created successfully.");
6670
}

0 commit comments

Comments
 (0)