{"id":13474888,"url":"https://github.com/sheerun/knex-migrate","last_synced_at":"2025-05-16T11:04:06.970Z","repository":{"id":10928955,"uuid":"67529800","full_name":"sheerun/knex-migrate","owner":"sheerun","description":"Modern database migration toolkit for knex.js","archived":false,"fork":false,"pushed_at":"2023-12-01T02:17:50.000Z","size":715,"stargazers_count":343,"open_issues_count":30,"forks_count":39,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-10T01:06:33.164Z","etag":null,"topics":["knex","migration"],"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/sheerun.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-06T17:12:01.000Z","updated_at":"2025-04-27T00:43:50.000Z","dependencies_parsed_at":"2024-01-14T20:17:20.035Z","dependency_job_id":"d5d22997-3fb5-45cd-9bab-79517bfe137a","html_url":"https://github.com/sheerun/knex-migrate","commit_stats":{"total_commits":91,"total_committers":9,"mean_commits":10.11111111111111,"dds":"0.10989010989010994","last_synced_commit":"409769486719e5ac26b1eca90d9e6ad89016c744"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheerun%2Fknex-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheerun%2Fknex-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheerun%2Fknex-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheerun%2Fknex-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sheerun","download_url":"https://codeload.github.com/sheerun/knex-migrate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"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":["knex","migration"],"created_at":"2024-07-31T16:01:15.696Z","updated_at":"2025-05-16T11:04:06.953Z","avatar_url":"https://github.com/sheerun.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"![Knex Migrate](http://i.imgur.com/MMWMf5T.png)\n\n[![Unix CI](https://img.shields.io/travis/sheerun/knex-migrate/master.svg)](https://travis-ci.org/sheerun/knex-migrate)\n[![Modern Node](https://img.shields.io/badge/modern-node-9BB48F.svg)](https://github.com/sheerun/modern-node)\n\n\u003e Modern migration toolkit for knex.js\n\n## Features\n\n- [x] 100% compatible with knex.js [migrations cli](http://knexjs.org/#Migrations)\n- [x] can migrate upto and downto any migration\n- [x] able to run individual migrations\n- [x] quickly rollback recent migrations\n- [x] redo feature: rollback and migrate again for quick testing\n- [x] runs migrations in transactions\n- [x] friendly ui 🌹\n\n## Installation\n\n```\nnpm install --save knex-migrate\n```\n\nYou should also install `knex` as it's a peer dependency of this package.\n\n## Usage\n\nFirst, init project with `knex init`, and then:\n\n```\nUsage\n  $ knex-migrate \u003ccommand\u003e [options]\n\nCommands\n  generate  Generate migration\n  pending   Lists all pending migrations\n  list      Lists all executed migrations\n  up        Performs all pending migrations\n  down      Rollbacks last migration\n  rollback  Rollbacks last batch of migrations\n  redo      Rollbacks last batch and performs all migrations\n\nOptions for \"up\" and \"down\":\n  --to, -t    Migrate upto (downto) specific version\n  --from, -f  Start migration from specific version\n  --only, -o  Migrate only specific version\n  --step, -s  Limit the number of migrations to apply\n\nGlobal options:\n  --cwd         Specify the working directory\n  --knexfile    Specify the knexfile path ($cwd/knexfile.js)\n  --migrations  Specify migrations path ($cwd/migrations)\n  --env         Specify environment ($KNEX_ENV || $NODE_ENV || 'development')\n  --raw         Disable transactions\n  --verbose     Be more verbose\n\nAs a convenience, you can skip --to flag, and just provide migration name.\n\nExamples\n  $ knex-migrate up                    # migrate to the latest version\n  $ knex-migrate up 20160905           # migrate to a specific version\n  $ knex-migrate up --to 20160905      # the same as above\n  $ knex-migrate up --only 201609085   # apply a single migration\n  $ knex-migrate up --step             # apply only the next migration\n  $ knex-migrate up --step 2           # apply only the next two migrations\n  $ knex-migrate down --to 0           # rollback all migrations\n  $ knex-migrate down                  # rollback single migration\n  $ knex-migrate down --step 2         # rollback the previous two migrations\n  $ knex-migrate rollback              # rollback previous \"up\"\n  $ knex-migrate redo --verbose        # rollback and migrate everything\n  $ knex-migrate generate create_users # generate migration creating users table\n```\n\n## Programmatic API\n\n```es6\nimport knexMigrate from 'knex-migrate'\n\n// It has following signature:\n// knexMigrate(command: String, flags: Object, progress: Function)\n\nasync function run() {\n  // Action can be: migrate, revert. Migration is migration name. For example:\n  // Doing migrate on 20170427093232_add_users\n  // Doing revert on 20170427093232_add_users\n  const log = ({ action, migration }) =\u003e\n    console.log('Doing ' + action + ' on ' + migration)\n\n  await knexMigrate('up', { to: '20170727093232' }, log)\n  await knexMigrate('down', { step: 2 }, log)\n  await knexMigrate('down', { to: 0 }, log)\n  await knexMigrate('up', {}, log)\n  await knexMigrate('redo', {}, log)\n  await knexMigrate('rollback', {}, log)\n  await knexMigrate('redo', {}, log)\n  await knexMigrate('down', { to: 0 }, log)\n}\n\nrun()\n```\n\n## Thank you\n\n- [@marcbachmann](https://github.com/marcbachmann) for inspiration and starting point ([knex-umzug](https://github.com/marcbachmann/knex-umzug) and [umzug-cli](https://github.com/marcbachmann/umzug-cli))\n- [@carlbennettnz](https://github.com/carlbennettnz) for suggesting and implementing `--step` option\n- [@chadxz](https://github.com/chadxz) for suggesting and implementing various improvements\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheerun%2Fknex-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsheerun%2Fknex-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheerun%2Fknex-migrate/lists"}