-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update sequelize config Change sequelize so it stores memory of which migrations and seeders have run in custom named tables * update package json command
- Loading branch information
Showing
1 changed file
with
25 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const rootENV = path.join(process.cwd(), '..', '.env'); | ||
const serverENV = path.join(process.cwd(), '.env'); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const rootENV = path.join(process.cwd(), "..", ".env"); | ||
const serverENV = path.join(process.cwd(), ".env"); | ||
const ENVPath = fs.existsSync(rootENV) ? rootENV : serverENV; | ||
require('dotenv').config({ path: ENVPath}); | ||
require("dotenv").config({ path: ENVPath }); | ||
|
||
const logger = require('./logger'); | ||
const logger = require("./logger"); | ||
const dbConfigOptions = { | ||
username: process.env.DB_USERNAME, | ||
password: process.env.DB_PASSWORD, | ||
database: process.env.DB_NAME, | ||
host: process.env.DB_HOSTNAME, | ||
dialect: 'mysql', | ||
seederStorage: 'json', | ||
logging: (msg) => logger.debug(msg), // change winston settings to 'debug' to see this log | ||
} | ||
username: process.env.DB_USERNAME, | ||
password: process.env.DB_PASSWORD, | ||
database: process.env.DB_NAME, | ||
host: process.env.DB_HOSTNAME, | ||
dialect: "mysql", | ||
seederStorage: "sequelize", | ||
seederStorageTableName: "sequelize_seeders", | ||
migrationStorageTableName: "sequelize_migrations", | ||
|
||
logging: (msg) => logger.debug(msg), // change winston settings to 'debug' to see this log | ||
}; | ||
|
||
if(process.env.MYSQL_SSL_ENABLED === "true"){ | ||
dbConfigOptions.ssl = true; | ||
dbConfigOptions.dialectOptions = { | ||
ssl: { | ||
require: true | ||
} | ||
} | ||
if (process.env.MYSQL_SSL_ENABLED === "true") { | ||
dbConfigOptions.ssl = true; | ||
dbConfigOptions.dialectOptions = { | ||
ssl: { | ||
require: true, | ||
}, | ||
}; | ||
} | ||
|
||
module.exports = { | ||
development: dbConfigOptions, | ||
production: dbConfigOptions | ||
production: dbConfigOptions, | ||
}; |