Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
achauve committed Nov 23, 2023
1 parent 13c5fa1 commit 06e9340
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/db/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ dotenv.config();

module.exports = {
development: {
username: process.env.PGUSER,
password: process.env.PGPASSWORD,
database: process.env.PGDATABASE,
port: process.env.PGPORT,
host: process.env.PGHOST,
dialect: "postgres",
url: process.env.DATABASE_URL,
dialectOptions: {
ssl: {
require: true,
Expand All @@ -13,8 +17,12 @@ module.exports = {
},
},
production: {
username: process.env.PGUSER,
password: process.env.PGPASSWORD,
database: process.env.PGDATABASE,
port: process.env.PGPORT,
host: process.env.PGHOST,
dialect: "postgres",
url: process.env.DATABASE_URL,
dialectOptions: {
ssl: {
require: false,
Expand Down
20 changes: 13 additions & 7 deletions src/db/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ import config from "../../services/config";
import psychologist from "./psychologist";

const env = process.env.NODE_ENV || "development";
const currentDbConfig = dbConfig[env];

export const sequelize = new Sequelize({
...dbConfig[env],
define: {
freezeTableName: true,
},
logging: config.postgre.logging ? console.log : false,
});
export const sequelize = new Sequelize(
currentDbConfig.database,
currentDbConfig.username,
currentDbConfig.password,
{
...currentDbConfig,
define: {
freezeTableName: true,
},
logging: config.postgre.logging ? console.log : false,
}
);

export const models = {
Psychologist: psychologist(sequelize),
Expand Down

0 comments on commit 06e9340

Please sign in to comment.