0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

🎨 updates for database configuration (#7975)

* 🎨  update configuration files: database

refs #7488

- no default database configuration
- production: default is MySQL

* 🎨  add transport stdout to production for now

refs #7488

- production will log to stdout and file for now
- to reduce the risk of confusing users
- users would not see any stdout and they don't know that Ghost logs into file only in production

* 🎨  sanitize database properties

refs #7488
This commit is contained in:
Katharina Irrgang 2017-02-11 19:02:12 +01:00 committed by Hannah Wolfe
parent 53bd7da063
commit d9e87aa793
6 changed files with 35 additions and 12 deletions

View file

@ -4,13 +4,6 @@
"host": "127.0.0.1",
"port": 2368
},
"database": {
"client": "sqlite3",
"debug": false,
"connection": {
"filename": "content/data/ghost.db"
}
},
"privacy": false,
"paths": {
"contentPath": "content/"

View file

@ -1,6 +1,7 @@
{
"url": "http://localhost:2368",
"database": {
"client": "sqlite3",
"connection": {
"filename": "content/data/ghost-dev.db"
},

View file

@ -1,10 +1,13 @@
{
"url": "http://my-ghost-blog.com",
"database": {
"client": "mysql",
"connection": {
"filename": "content/data/ghost.db"
},
"debug": false
"host" : "127.0.0.1",
"user" : "root",
"password" : "",
"database" : "ghost"
}
},
"paths": {
"contentPath": "content/"
@ -14,6 +17,6 @@
"rotation": {
"enabled": true
},
"transports": ["file"]
"transports": ["file", "stdout"]
}
}

View file

@ -1,10 +1,12 @@
{
"url": "http://127.0.0.1:2369",
"database": {
"client": "sqlite3",
"connection": {
"filename": "content/data/ghost-test.db"
},
"useNullAsDefault": true
"useNullAsDefault": true,
"debug": false
},
"server": {
"port": 2369

View file

@ -40,7 +40,9 @@ _private.loadNconf = function loadNconf(options) {
nconf.makePathsAbsolute = localUtils.makePathsAbsolute.bind(nconf);
nconf.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
nconf.getContentPath = localUtils.getContentPath.bind(nconf);
nconf.sanitizeDatabaseProperties = localUtils.sanitizeDatabaseProperties.bind(nconf);
nconf.sanitizeDatabaseProperties();
nconf.makePathsAbsolute(nconf.get('paths'), 'paths');
nconf.makePathsAbsolute(nconf.get('database:connection'), 'database:connection');

View file

@ -81,3 +81,25 @@ exports.getContentPath = function getContentPath(type) {
throw new Error('getContentPath was called with: ' + type);
}
};
/**
* nconf merges all database keys together and this can be confusing
* e.g. production default database is sqlite, but you override the configuration with mysql
*
* this.clear('key') does not work
* https://github.com/indexzero/nconf/issues/235#issuecomment-257606507
*/
exports.sanitizeDatabaseProperties = function sanitizeDatabaseProperties() {
var database = this.get('database');
if (this.get('database:client') === 'mysql') {
delete database.connection.filename;
} else {
delete database.connection.host;
delete database.connection.user;
delete database.connection.password;
delete database.connection.database;
}
this.set('database', database);
};