UNPKG

1.27 kBJavaScriptView Raw
1'use strict'
2
3const cli = require('heroku-cli-util')
4
5async function run(context, heroku) {
6 const host = require('../../lib/host')
7 const fetcher = require('../../lib/fetcher')(heroku)
8 let { app, args, flags } = context
9
10 const db = await fetcher.addon(app, args.database)
11
12 await cli.confirmApp(app, flags.confirm, `WARNING: Destructive action
13This command will affect the database ${cli.color.addon(db.name)}
14This will delete ${cli.color.cyan(args.link)} along with the tables and views created within it.
15This may have adverse effects for software written against the ${cli.color.cyan(args.link)} schema.
16`)
17 await cli.action(`Destroying link ${cli.color.cyan(args.link)} from ${cli.color.addon(db.name)}`, async function () {
18 await heroku.delete(`/client/v11/databases/${db.id}/links/${encodeURIComponent(args.link)}`, { host: host(db) })
19 }())
20}
21
22module.exports = {
23 topic: 'pg',
24 command: 'links:destroy',
25 description: 'destroys a link between data stores',
26 help: `Example:
27
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 }, run)
34}