# knex-scripts

> Knex utilities to interact with Postgres database.

Latest version **0.3.6** (published 2022-11-01) · MIT license · 34 weekly downloads

## Install

```sh
npm install knex-scripts
pnpm add knex-scripts
yarn add knex-scripts
bun add knex-scripts
```

Provides the command `knex-scripts`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.6 |
| Published | 2022-11-01 |
| First published | 2018-02-06 |
| Weekly downloads | 34 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Greg Bergé |
| Maintainers | neoziro |

## Links

- npm: https://www.npmjs.com/package/knex-scripts
- npm.io page: https://npm.io/package/knex-scripts

## Dependencies (10)

- [mz](https://npm.io/package/mz.md) ^2.7.0
- [chalk](https://npm.io/package/chalk.md) ^3.0.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.3
- [liftoff](https://npm.io/package/liftoff.md) ^3.1.0
- [tildify](https://npm.io/package/tildify.md) ^2.0.0
- [v8flags](https://npm.io/package/v8flags.md) ^3.1.3
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [commander](https://npm.io/package/commander.md) ^5.0.0
- [interpret](https://npm.io/package/interpret.md) ^2.0.0
- [tiny-glob](https://npm.io/package/tiny-glob.md) ^0.2.6

## Recent versions

- 0.3.6 (latest) — 2022-11-01
- 0.3.5 — 2022-11-01
- 0.3.4 — 2022-11-01
- 0.3.3 — 2020-03-29
- 0.3.2 — 2020-03-03
- 0.3.1 — 2019-09-25
- 0.3.0 — 2019-08-28
- 0.2.1 — 2018-02-28
- 0.2.0 — 2018-02-28
- 0.1.4 — 2018-02-13
- 0.1.3 — 2018-02-13
- 0.1.2 — 2018-02-12
- 0.1.1 — 2018-02-12
- 0.1.0 — 2018-02-12
- 0.0.2 — 2018-02-10
- … 1 more at https://npm.io/package/knex-scripts/versions

## README

# Knex Scripts

[![Build Status](https://travis-ci.org/smooth-code/knex-scripts.svg?branch=master)](https://travis-ci.org/smooth-code/knex-scripts)

Knex utilities to interact with Postgres database.

```
npm install knex-scripts
```

## Command Line Usage

```
  Usage: cli [options] [command]


  Options:

  -V, --version               output the version number
  --docker                    Use docker.
  --docker-service [service]  Docker service name, default: "postgres".
  --knexfile [path]           Specify the knexfile path.
  --cwd [path]                Specify the working directory.
  --env [name]                environment, default: process.env.NODE_ENV || development
  -h, --help                  output usage information


  Commands:

  create           Create database.
  drop             Drop database.
  dump             Dump database.
  load             Load database.
  check-structure  Check structure.
  truncate         Truncate all tables.
```

## Node API Usage

```js
import knex from 'knex'
import { truncate } from 'knex-scripts'
import config from './knexfile'

// Truncate all database
truncate({ getKnex: () => knex(config) })
  .then(() => console.log('Truncated'))
  .catch(console.error)
```

## Configuration

```js
// knexfile.js
const config = {
  knexScripts: {
    docker: false,
    structurePath: 'db/structure.sql',
  },
  development: {
    client: 'postgresql',
    connection: {
      user: 'postgres',
      database: 'development',
      timezone: 'utc',
    },
  },
}

module.exports = config
```

## License

MIT

---
_Source: https://npm.io/package/knex-scripts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
