UNPKG

1.04 kBJavaScriptView Raw
1'use strict'
2
3const co = require('co')
4const cli = require('heroku-cli-util')
5
6function * run (context, heroku) {
7 const fetcher = require('../../lib/fetcher')(heroku)
8 const host = require('../../lib/host')
9 const util = require('../../lib/util')
10
11 const {app, args} = context
12
13 let db = yield fetcher.addon(app, args.database)
14 if (util.starterPlan(db)) throw new Error('This operation is not supported by Hobby tier databases.')
15
16 yield cli.action(`Resetting permissions for default role to factory settings`, co(function * () {
17 yield heroku.post(`/postgres/v0/databases/${db.name}/repair-default`, {host: host(db)})
18 }))
19}
20
21module.exports = {
22 topic: 'pg',
23 command: 'credentials:repair-default',
24 description: 'repair the permissions of the default credential within database',
25 needsApp: true,
26 needsAuth: true,
27 help: `
28Example Usage:
29 heroku pg:credentials:repair-default postgresql-something-12345 --name cred-name
30`,
31 args: [{name: 'database', optional: true}],
32 run: cli.command({preauth: true}, co.wrap(run))
33}