fix(db): remove database configuration option, hardcode 'fxa' (#314) r=@vladikoff
Fixes #290
This commit is contained in:
Родитель
d7cb9edf83
Коммит
c2e21dd9e0
|
@ -9,6 +9,7 @@ var logger = require('../lib/logging')('bin.db_patcher')
|
|||
var patcher = require('mysql-patcher')
|
||||
|
||||
var patch = require('../lib/db/patch')
|
||||
const constants = require('../lib/constants')
|
||||
|
||||
// set some options
|
||||
var options = Object.assign({}, config.master)
|
||||
|
@ -19,6 +20,7 @@ options.patchLevel = patch.level
|
|||
options.mysql = mysql
|
||||
options.createDatabase = true
|
||||
options.reversePatchAllowed = false
|
||||
options.database = constants.DATABASE_NAME
|
||||
|
||||
patcher.patch(options, function(err) {
|
||||
if (err) {
|
||||
|
|
|
@ -81,11 +81,6 @@ module.exports = function (fs, path, url, convict) {
|
|||
default: '',
|
||||
env: 'MYSQL_PASSWORD',
|
||||
},
|
||||
database: {
|
||||
doc: 'The database to connect to for MySql',
|
||||
default: 'fxa',
|
||||
env: 'MYSQL_DATABASE',
|
||||
},
|
||||
host: {
|
||||
doc: 'The host to connect to for MySql',
|
||||
default: '127.0.0.1',
|
||||
|
@ -127,11 +122,6 @@ module.exports = function (fs, path, url, convict) {
|
|||
default: '',
|
||||
env: 'MYSQL_SLAVE_PASSWORD',
|
||||
},
|
||||
database: {
|
||||
doc: 'The database to connect to for MySql',
|
||||
default: 'fxa',
|
||||
env: 'MYSQL_SLAVE_DATABASE',
|
||||
},
|
||||
host: {
|
||||
doc: 'The host to connect to for MySql',
|
||||
default: '127.0.0.1',
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
module.exports = Object.freeze({
|
||||
DATABASE_NAME: 'fxa'
|
||||
})
|
|
@ -13,6 +13,7 @@ const patch = require('./patch')
|
|||
const dbUtil = require('./util')
|
||||
|
||||
const REQUIRED_CHARSET = 'UTF8MB4_BIN'
|
||||
const DATABASE_NAME = require('../constants').DATABASE_NAME
|
||||
|
||||
// http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
|
||||
const ER_TOO_MANY_CONNECTIONS = 1040
|
||||
|
@ -37,6 +38,8 @@ module.exports = function (log, error) {
|
|||
|
||||
// make a pool of connections that we can draw from
|
||||
function MySql(options) {
|
||||
options.master.database = DATABASE_NAME
|
||||
options.slave.database = DATABASE_NAME
|
||||
this.options = options
|
||||
this.ipHmacKey = options.ipHmacKey
|
||||
|
||||
|
@ -1321,4 +1324,3 @@ module.exports = function (log, error) {
|
|||
|
||||
return MySql
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const assert = require('insist')
|
||||
const constants = require('../../lib/constants')
|
||||
describe('constants', () => {
|
||||
it(
|
||||
'constants exports DATABASE_NAME fxa',
|
||||
() => {
|
||||
constants.DATABASE_NAME = 'test'
|
||||
assert.equal(constants.DATABASE_NAME, 'fxa')
|
||||
})
|
||||
})
|
|
@ -220,7 +220,7 @@ describe('DB metrics', () => {
|
|||
db_dnsname: 'foo',
|
||||
db_username: 'bar',
|
||||
db_password: 'baz',
|
||||
db_name: 'qux'
|
||||
db_name: 'fxa'
|
||||
}
|
||||
}, new Date(1977, 5, 10, 10, 30))
|
||||
.then(function () {
|
||||
|
@ -234,13 +234,13 @@ describe('DB metrics', () => {
|
|||
assert.equal(options.master.host, 'foo', 'mysql.connect master.host option was correct')
|
||||
assert.equal(options.master.user, 'bar', 'mysql.connect master.user option was correct')
|
||||
assert.equal(options.master.password, 'baz', 'mysql.connect master.password option was correct')
|
||||
assert.equal(options.master.database, 'qux', 'mysql.connect master.database option was correct')
|
||||
assert.equal(options.master.database, 'fxa', 'mysql.connect master.database option was correct')
|
||||
assert.equal(typeof options.slave, 'object', 'mysql.connect slave option was object')
|
||||
assert.equal(Object.keys(options.slave).length, 4, 'mysql.connect slave option had correct number of properties')
|
||||
assert.equal(options.slave.host, 'foo', 'mysql.connect slave.host option was correct')
|
||||
assert.equal(options.slave.user, 'bar', 'mysql.connect slave.user option was correct')
|
||||
assert.equal(options.slave.password, 'baz', 'mysql.connect slave.password option was correct')
|
||||
assert.equal(options.slave.database, 'qux', 'mysql.connect slave.database option was correct')
|
||||
assert.equal(options.slave.database, 'fxa', 'mysql.connect slave.database option was correct')
|
||||
assert.equal(options.patchKey, 'schema-patch-level', 'mysql.connect patchKey option was correct')
|
||||
|
||||
assert.equal(readMultiple.callCount, 1, 'readMultiple was called once')
|
||||
|
|
Загрузка…
Ссылка в новой задаче