1 | 'use strict'
|
2 |
|
3 | const co = require('co')
|
4 | const cli = require('heroku-cli-util')
|
5 |
|
6 | function * 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 |
|
21 | module.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: `
|
28 | Example 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 | }
|