{"id":18234117,"url":"https://github.com/smartprix/knex-utils","last_synced_at":"2025-10-15T17:54:36.706Z","repository":{"id":57161142,"uuid":"154780624","full_name":"smartprix/knex-utils","owner":"smartprix","description":"Some utilities for knex, and a simple cli to create and refresh DBs","archived":false,"fork":false,"pushed_at":"2019-10-22T04:45:34.000Z","size":126,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T05:03:25.433Z","etag":null,"topics":["cli","db","development","development-tools","js","knex","migrations","postgres","refresh"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smartprix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-26T05:13:02.000Z","updated_at":"2024-08-24T00:29:45.000Z","dependencies_parsed_at":"2022-09-09T07:40:16.375Z","dependency_job_id":null,"html_url":"https://github.com/smartprix/knex-utils","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartprix%2Fknex-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartprix%2Fknex-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartprix%2Fknex-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartprix%2Fknex-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartprix","download_url":"https://codeload.github.com/smartprix/knex-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247082726,"owners_count":20880709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","db","development","development-tools","js","knex","migrations","postgres","refresh"],"created_at":"2024-11-04T17:03:44.789Z","updated_at":"2025-10-15T17:54:31.667Z","avatar_url":"https://github.com/smartprix.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# knex-utils\n\n\u003ca href=\"https://www.npmjs.com/package/@smpx/knex-utils\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@smpx/knex-utils.svg\" alt=\"Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/@smpx/knex-utils\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@smpx/knex-utils.svg\" alt=\"Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/@smpx/knex-utils\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@smpx/knex-utils.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://david-dm.org/smartprix/knex-utils\"\u003e\u003cimg src=\"https://david-dm.org/smartprix/knex-utils/status.svg\" alt=\"Dependencies\"\u003e\u003c/a\u003e\n\u003ca href=\"https://david-dm.org/smartprix/knex-utils?type=dev\"\u003e\u003cimg src=\"https://david-dm.org/smartprix/knex-utils/dev-status.svg\" alt=\"Dev Dependencies\"\u003e\u003c/a\u003e\n\nIt is a set of utility functions for use with knex and knex migrations. Mostly aimed at PostgreSQL.\n\n## CLI\n\n```txt\nUsage: knex-utils [options] [command]\n\nOptions:\n  -V, --version     output the version number\n  -h, --help        output usage information\n\nCommands:\n  refresh\n  create [options]\n  consolidate\n```\n\n### For `knex-utils create`\n\n```txt\nUsage: knex-utils create [options]\n\nOptions:\n  -m, --migrate  Run migrations too after creating DB\n  -h, --help     output usage information\n```\n\n## KnexFile\n\nThe cwd should have a knexfile.js, this is used by knex to connect to the DB.\n\nReference : https://knexjs.org/#knexfile\n\n## Consolidate\n\nNOTE: **ONLY WORKS WITH POSTGRESQL**\n\nTool to consolidate all existing schema migrations into one migration and corresponding tables folder with one file for each table.\n\n### Supported types for columns\n\n- integer\n- increments\n- string\n- jsonb\n- timestamp\n- text\n- boolean\n- float\n- decimal\n- enum\n- specificType:\n    - citext\n\n### Supported Modifiers\n\n- unique\n- index\n- primary\n- composite primary keys\n- nullable\n- notNullable\n- defaultTo\n- maxLength for string\n- numeric_precision for numeric\n\n### TODO\n\n- Handle Partitions:\n    - Could look at code for [Migra](https://github.com/djrobstep/migra)\n    - https://dba.stackexchange.com/questions/40441/get-all-partition-names-for-a-table\n\n### Not supported (for now?)\n\n- Custom indexes not on columns directly\n- Functions\n- native types\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartprix%2Fknex-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartprix%2Fknex-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartprix%2Fknex-utils/lists"}