Skip to content

Commit

Permalink
Update db
Browse files Browse the repository at this point in the history
  • Loading branch information
mfjkri committed Oct 1, 2023
1 parent 3c57e59 commit b625686
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/database/database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client } from "pg";
import { Sequelize } from "sequelize";
import { Options, Sequelize } from "sequelize";

import pgtools from "pgtools";

Expand All @@ -16,6 +16,7 @@ export async function connectDB(dbName?: string) {
Name: name,
User: config.DBUsername,
Password: config.DBPassword,
LocalDB: config.UseLocalDB,
});

try {
Expand Down Expand Up @@ -45,21 +46,25 @@ type Config = {
Name: string;
User: string;
Password: string;
LocalDB: boolean;
};

function connect(config: Config) {
const { Hostname, Port, Name, User, Password } = config;
return new Sequelize(Name, User, Password, {
const { Hostname, Port, Name, User, Password, LocalDB } = config;
const options: Options = {
host: Hostname,
port: Port,
dialect: "postgres",
// dialectOptions: {
// ssl: {
// require: true,
// rejectUnauthorized: false,
// },
// },
});
};
if (!LocalDB) {
options.dialectOptions = {
ssl: {
require: true,
rejectUnauthorized: false,
},
};
}
return new Sequelize(Name, User, Password, options);
}
export async function createBackupDB() {
const config = getConfig();
Expand Down

0 comments on commit b625686

Please sign in to comment.