1 | 'use strict'
|
2 |
|
3 | const cli = require('heroku-cli-util')
|
4 |
|
5 | async function run(context, heroku) {
|
6 | const host = require('../../lib/host')
|
7 | const util = require('../../lib/util')
|
8 | const fetcher = require('../../lib/fetcher')(heroku)
|
9 | const { app, args } = context
|
10 |
|
11 | const db = await fetcher.addon(app, args.database)
|
12 |
|
13 | if (util.starterPlan(db)) throw new Error('This operation is not supported by Hobby tier databases.')
|
14 | if (util.legacyPlan(db)) throw new Error('This operation is not supported by Legacy-tier databases.')
|
15 |
|
16 | let settings = await heroku.get(`/postgres/v0/databases/${db.id}/config`, { host: host(db) })
|
17 | cli.styledHeader(db.name)
|
18 | let remapped = Object.keys(settings).reduce((s, key) => {
|
19 | s[key.replace(/_/g, '-')] = settings[key]['value']
|
20 | return s
|
21 | }, {})
|
22 | cli.styledObject(remapped)
|
23 | }
|
24 |
|
25 | module.exports = {
|
26 | topic: 'pg',
|
27 | command: 'settings',
|
28 | description: 'show your current database settings',
|
29 | needsApp: true,
|
30 | needsAuth: true,
|
31 | args: [{ name: 'database', optional: true }],
|
32 | run: cli.command({ preauth: true }, run)
|
33 | }
|