update debug UI to use PG

This commit is contained in:
timothycarambat
2023-09-28 09:07:22 -07:00
parent 9c107f8d03
commit 1cb3f2404c
8 changed files with 13 additions and 14 deletions
+1
View File
@@ -6,3 +6,4 @@ SYS_PASSWORD=password
JWT_SECRET="YoUr_RaNd0M_sTr1nG"
# STORAGE_DIR=
DATABASE_CONNECTION_STRING="postgresql://user:password@host:port/database
+4 -2
View File
@@ -7,7 +7,6 @@ const { dumpENV } = require("../utils/env");
const { reqBody, userFromSession } = require("../utils/http");
const { getGitVersion, getDiskStorage } = require("../utils/metrics");
const { validatedRequest } = require("../utils/middleware/validatedRequest");
// const { validateTablePragmas } = require("../utils/database");
function systemEndpoints(app) {
if (!app) return;
@@ -38,7 +37,10 @@ function systemEndpoints(app) {
});
app.get("/migrate", async (_, response) => {
// await validateTablePragmas(true);
const execSync = require("child_process").execSync;
execSync("npx prisma migrate dev --name init", {
stdio: "inherit",
});
response.sendStatus(200).end();
});
+1 -2
View File
@@ -54,9 +54,8 @@ app.all("*", function (_, response) {
app
.listen(process.env.SERVER_PORT || 3001, async () => {
// await validateTablePragmas();
await systemInit();
// setupDebugger(apiRouter); //TODO: DEBUGGER
setupDebugger(apiRouter);
console.log(
`Example app listening on port ${process.env.SERVER_PORT || 3001}`
);
-1
View File
@@ -129,7 +129,6 @@ const Organization = {
},
whereWithOwner: async function (
// TODO
userId,
clause = {},
limit = null,
+1
View File
@@ -33,6 +33,7 @@
"moment": "^2.29.4",
"multer": "^1.4.5-lts.1",
"openai": "^3.3.0",
"pg": "^8.11.3",
"pinecone-client": "^1.1.0",
"posthog-node": "^3.1.2",
"prisma": "^5.3.1",
+1 -1
View File
@@ -6,7 +6,7 @@ generator client {
// After swapping run `yarn prisma:setup` from the root directory to migrate the database
datasource db {
provider = "postgresql"
url = "postgresql://tim:tdc1994@localhost:5432/vdbms"
url = env("DATABASE_CONNECTION_STRING")
}
model users {
-3
View File
@@ -4,17 +4,14 @@ function handleError(err = null) {
}
async function preSave(_req, _res, args, next) {
await args.db.client.query("PRAGMA foreign_keys = ON", handleError);
next();
}
async function postSave(_req, _res, args, next) {
await args.db.client.query("PRAGMA foreign_keys = ON", handleError);
next();
}
async function preList(_req, _res, args, next) {
await args.db.client.query("PRAGMA foreign_keys = ON", handleError);
next();
}
+5 -5
View File
@@ -32,8 +32,8 @@ function setupDebugger(app) {
"/debug/vdbms",
dbAdmin({
config: {
sqlite: {
database: path.resolve(__dirname, "../../storage/vdbms.db"),
pg: {
connectionString: process.env.DATABASE_CONNECTION_STRING,
},
admin: {
settings: path.resolve(__dirname, "../../storage/settings.json"),
@@ -53,9 +53,9 @@ function setupDebugger(app) {
},
},
custom: {
ensurePragma: {
events: path.resolve(__dirname, "dbevents.js"),
},
// ensurePragma: {
// events: path.resolve(__dirname, "dbevents.js"),
// },
},
})
);