feat(migrate): quality alert migrated
This commit is contained in:
46
backend/utils/pgConnectToLst.utils.ts
Normal file
46
backend/utils/pgConnectToLst.utils.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import pkg from "pg";
|
||||
const { Client } = pkg;
|
||||
|
||||
const v1client = new Client({
|
||||
host: "localhost",
|
||||
port: 5432,
|
||||
user: "postgres",
|
||||
password: "obelix",
|
||||
database: "lst",
|
||||
});
|
||||
|
||||
const v2client = new Client({
|
||||
host: "localhost",
|
||||
port: 5432,
|
||||
user: "postgres",
|
||||
password: "obelix",
|
||||
database: "lst_db",
|
||||
});
|
||||
|
||||
export const v1QueryRun= async (query:string)=> {
|
||||
try {
|
||||
await v1client.connect();
|
||||
|
||||
const res = await v1client.query(query);
|
||||
|
||||
console.log("Rows affected:", res.rowCount);
|
||||
} catch (err) {
|
||||
console.error("Error running query:", err);
|
||||
} finally {
|
||||
await v1client.end();
|
||||
}
|
||||
}
|
||||
|
||||
export const v2QueryRun = async (query:string)=> {
|
||||
try {
|
||||
await v2client.connect();
|
||||
|
||||
const res = await v2client.query(query);
|
||||
|
||||
console.log("Rows affected:", res.rowCount);
|
||||
} catch (err) {
|
||||
console.error("Error running query:", err);
|
||||
} finally {
|
||||
await v2client.end();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user