diff --git a/src/db/config/config.js b/src/db/config/config.js index 6543b9fd..ae3479a3 100644 --- a/src/db/config/config.js +++ b/src/db/config/config.js @@ -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, @@ -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, diff --git a/src/db/models/index.ts b/src/db/models/index.ts index 425796e9..255fa398 100644 --- a/src/db/models/index.ts +++ b/src/db/models/index.ts @@ -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),