0.3.6 • Published 2 years ago

knex-scripts v0.3.6

Weekly downloads
43
License
MIT
Repository
-
Last release
2 years ago

Knex Scripts

Build Status

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

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

// 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

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago