UNPKG

729 BJavaScriptView Raw
1'use strict'
2
3const co = require('co')
4const cli = require('heroku-cli-util')
5const pg = require('heroku-pg')
6
7function * run (context, heroku) {
8 let db = yield pg.fetcher(heroku).database(context.app, context.args.database)
9
10 let query = `
11SELECT * FROM pg_available_extensions WHERE name IN (SELECT unnest(string_to_array(current_setting('extwlist.extensions'), ',')))
12`
13
14 let output = yield pg.psql.exec(db, query)
15 process.stdout.write(output)
16}
17
18const cmd = {
19 topic: 'pg',
20 description: 'list available and installed extensions',
21 needsApp: true,
22 needsAuth: true,
23 args: [{name: 'database', optional: true}],
24 run: cli.command(co.wrap(run))
25}
26
27module.exports = [
28 Object.assign({command: 'extensions'}, cmd)
29]