1 | 'use strict'
|
2 |
|
3 | const cli = require('heroku-cli-util')
|
4 | const co = require('co')
|
5 |
|
6 | function * run (context, heroku) {
|
7 | const host = require('../../lib/host')
|
8 | const fetcher = require('../../lib/fetcher')(heroku)
|
9 | let {app, args, flags} = context
|
10 |
|
11 | const db = yield fetcher.addon(app, args.database)
|
12 |
|
13 | yield cli.confirmApp(app, flags.confirm, `WARNING: Destructive action
|
14 | This command will affect the database ${cli.color.addon(db.name)}
|
15 | This will delete ${cli.color.cyan(args.link)} along with the tables and views created within it.
|
16 | This may have adverse effects for software written against the ${cli.color.cyan(args.link)} schema.
|
17 | `)
|
18 | yield cli.action(`Destroying link ${cli.color.cyan(args.link)} from ${cli.color.addon(db.name)}`, co(function * () {
|
19 | yield heroku.delete(`/client/v11/databases/${db.name}/links/${encodeURIComponent(args.link)}`, {host: host(db)})
|
20 | }))
|
21 | }
|
22 |
|
23 | module.exports = {
|
24 | topic: 'pg',
|
25 | command: 'links:destroy',
|
26 | description: 'destroys a link between data stores',
|
27 | help: `Example:
|
28 | heroku pg:links:destroy HEROKU_POSTGRESQL_CERULEAN redis-symmetrical-100`,
|
29 | needsApp: true,
|
30 | needsAuth: true,
|
31 | args: [{name: 'database'}, {name: 'link'}],
|
32 | flags: [{name: 'confirm', char: 'c', hasValue: true}],
|
33 | run: cli.command({preauth: true}, co.wrap(run))
|
34 | }
|