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:
parent
53bd7da063
commit
d9e87aa793
6 changed files with 35 additions and 12 deletions
|
@ -4,13 +4,6 @@
|
||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
"port": 2368
|
"port": 2368
|
||||||
},
|
},
|
||||||
"database": {
|
|
||||||
"client": "sqlite3",
|
|
||||||
"debug": false,
|
|
||||||
"connection": {
|
|
||||||
"filename": "content/data/ghost.db"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"privacy": false,
|
"privacy": false,
|
||||||
"paths": {
|
"paths": {
|
||||||
"contentPath": "content/"
|
"contentPath": "content/"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"url": "http://localhost:2368",
|
"url": "http://localhost:2368",
|
||||||
"database": {
|
"database": {
|
||||||
|
"client": "sqlite3",
|
||||||
"connection": {
|
"connection": {
|
||||||
"filename": "content/data/ghost-dev.db"
|
"filename": "content/data/ghost-dev.db"
|
||||||
},
|
},
|
||||||
|
|
11
core/server/config/env/config.production.json
vendored
11
core/server/config/env/config.production.json
vendored
|
@ -1,10 +1,13 @@
|
||||||
{
|
{
|
||||||
"url": "http://my-ghost-blog.com",
|
"url": "http://my-ghost-blog.com",
|
||||||
"database": {
|
"database": {
|
||||||
|
"client": "mysql",
|
||||||
"connection": {
|
"connection": {
|
||||||
"filename": "content/data/ghost.db"
|
"host" : "127.0.0.1",
|
||||||
},
|
"user" : "root",
|
||||||
"debug": false
|
"password" : "",
|
||||||
|
"database" : "ghost"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"contentPath": "content/"
|
"contentPath": "content/"
|
||||||
|
@ -14,6 +17,6 @@
|
||||||
"rotation": {
|
"rotation": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
"transports": ["file"]
|
"transports": ["file", "stdout"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
core/server/config/env/config.testing.json
vendored
4
core/server/config/env/config.testing.json
vendored
|
@ -1,10 +1,12 @@
|
||||||
{
|
{
|
||||||
"url": "http://127.0.0.1:2369",
|
"url": "http://127.0.0.1:2369",
|
||||||
"database": {
|
"database": {
|
||||||
|
"client": "sqlite3",
|
||||||
"connection": {
|
"connection": {
|
||||||
"filename": "content/data/ghost-test.db"
|
"filename": "content/data/ghost-test.db"
|
||||||
},
|
},
|
||||||
"useNullAsDefault": true
|
"useNullAsDefault": true,
|
||||||
|
"debug": false
|
||||||
},
|
},
|
||||||
"server": {
|
"server": {
|
||||||
"port": 2369
|
"port": 2369
|
||||||
|
|
|
@ -40,7 +40,9 @@ _private.loadNconf = function loadNconf(options) {
|
||||||
nconf.makePathsAbsolute = localUtils.makePathsAbsolute.bind(nconf);
|
nconf.makePathsAbsolute = localUtils.makePathsAbsolute.bind(nconf);
|
||||||
nconf.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
|
nconf.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
|
||||||
nconf.getContentPath = localUtils.getContentPath.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('paths'), 'paths');
|
||||||
nconf.makePathsAbsolute(nconf.get('database:connection'), 'database:connection');
|
nconf.makePathsAbsolute(nconf.get('database:connection'), 'database:connection');
|
||||||
|
|
||||||
|
|
|
@ -81,3 +81,25 @@ exports.getContentPath = function getContentPath(type) {
|
||||||
throw new Error('getContentPath was called with: ' + 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);
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue