feat(db manual fixes): added a way to fix manual db changes as needed
This commit is contained in:
@@ -17,7 +17,10 @@ import { printers } from "./src/internal/ocp/printers/printers.js";
|
|||||||
import { setupRoutes } from "./src/internal/routerHandler/routeHandler.js";
|
import { setupRoutes } from "./src/internal/routerHandler/routeHandler.js";
|
||||||
import { baseModules } from "./src/internal/system/controller/modules/baseModules.js";
|
import { baseModules } from "./src/internal/system/controller/modules/baseModules.js";
|
||||||
import { baseSettings } from "./src/internal/system/controller/settings/baseSettings.js";
|
import { baseSettings } from "./src/internal/system/controller/settings/baseSettings.js";
|
||||||
import { addListeners } from "./src/internal/system/utlis/addListeners.js";
|
import {
|
||||||
|
addListeners,
|
||||||
|
manualFixes,
|
||||||
|
} from "./src/internal/system/utlis/addListeners.js";
|
||||||
import { swaggerOptions } from "./src/pkg/apiDocs/swaggerOptions.js";
|
import { swaggerOptions } from "./src/pkg/apiDocs/swaggerOptions.js";
|
||||||
import { auth } from "./src/pkg/auth/auth.js";
|
import { auth } from "./src/pkg/auth/auth.js";
|
||||||
import { db } from "./src/pkg/db/db.js";
|
import { db } from "./src/pkg/db/db.js";
|
||||||
@@ -205,6 +208,9 @@ const main = async () => {
|
|||||||
v1Listener();
|
v1Listener();
|
||||||
addListeners();
|
addListeners();
|
||||||
userMigrate();
|
userMigrate();
|
||||||
|
|
||||||
|
// some temp fixes
|
||||||
|
manualFixes();
|
||||||
}, 5 * 1000);
|
}, 5 * 1000);
|
||||||
|
|
||||||
// start the server up
|
// start the server up
|
||||||
|
|||||||
@@ -59,3 +59,21 @@ export const addListeners = async () => {
|
|||||||
log.info({}, "Error deleting bad inv data");
|
log.info({}, "Error deleting bad inv data");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const manualFixes = async () => {
|
||||||
|
const fixQuery = `ALTER TABLE "serverData" ADD CONSTRAINT "serverData_name_unique" UNIQUE("name");`;
|
||||||
|
|
||||||
|
const log = createLogger({ module: "utils", subModule: "manual fixes" });
|
||||||
|
const client = new Client({
|
||||||
|
connectionString: `postgresql://${process.env.DATABASE_USER}:${process.env.DATABASE_PASSWORD}@${process.env.DATABASE_HOST}:${process.env.DATABASE_PORT}/${process.env.DATABASE_DB}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
await client.connect();
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info({}, "Running the manual fix");
|
||||||
|
await client.query(fixQuery);
|
||||||
|
} catch (e) {
|
||||||
|
log.info({ error: e }, "Fix was not completed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user