https://github.com/smartprix/knex-utils
Some utilities for knex, and a simple cli to create and refresh DBs
https://github.com/smartprix/knex-utils
cli db development development-tools js knex migrations postgres refresh
Last synced: about 2 months ago
JSON representation
Some utilities for knex, and a simple cli to create and refresh DBs
- Host: GitHub
- URL: https://github.com/smartprix/knex-utils
- Owner: smartprix
- License: mit
- Created: 2018-10-26T05:13:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-22T04:45:34.000Z (over 5 years ago)
- Last Synced: 2025-03-25T05:03:25.433Z (2 months ago)
- Topics: cli, db, development, development-tools, js, knex, migrations, postgres, refresh
- Language: JavaScript
- Homepage:
- Size: 123 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# knex-utils
It is a set of utility functions for use with knex and knex migrations. Mostly aimed at PostgreSQL.
## CLI
```txt
Usage: knex-utils [options] [command]Options:
-V, --version output the version number
-h, --help output usage informationCommands:
refresh
create [options]
consolidate
```### For `knex-utils create`
```txt
Usage: knex-utils create [options]Options:
-m, --migrate Run migrations too after creating DB
-h, --help output usage information
```## KnexFile
The cwd should have a knexfile.js, this is used by knex to connect to the DB.
Reference : https://knexjs.org/#knexfile
## Consolidate
NOTE: **ONLY WORKS WITH POSTGRESQL**
Tool to consolidate all existing schema migrations into one migration and corresponding tables folder with one file for each table.
### Supported types for columns
- integer
- increments
- string
- jsonb
- timestamp
- text
- boolean
- float
- decimal
- enum
- specificType:
- citext### Supported Modifiers
- unique
- index
- primary
- composite primary keys
- nullable
- notNullable
- defaultTo
- maxLength for string
- numeric_precision for numeric### TODO
- Handle Partitions:
- Could look at code for [Migra](https://github.com/djrobstep/migra)
- https://dba.stackexchange.com/questions/40441/get-all-partition-names-for-a-table### Not supported (for now?)
- Custom indexes not on columns directly
- Functions
- native types