{"id":28070146,"url":"https://github.com/neverbot/node-mongodb-migrations","last_synced_at":"2026-05-05T23:31:51.482Z","repository":{"id":44663659,"uuid":"116015808","full_name":"neverbot/node-mongodb-migrations","owner":"neverbot","description":"Abstract migration framework for node","archived":false,"fork":false,"pushed_at":"2022-02-01T10:31:57.000Z","size":107,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-10-04T23:46:35.777Z","etag":null,"topics":["migrations","mongo","node","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"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/neverbot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-02T13:03:45.000Z","updated_at":"2019-08-19T12:25:57.000Z","dependencies_parsed_at":"2022-09-14T07:24:21.200Z","dependency_job_id":null,"html_url":"https://github.com/neverbot/node-mongodb-migrations","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/neverbot/node-mongodb-migrations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neverbot%2Fnode-mongodb-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neverbot%2Fnode-mongodb-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neverbot%2Fnode-mongodb-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neverbot%2Fnode-mongodb-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neverbot","download_url":"https://codeload.github.com/neverbot/node-mongodb-migrations/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neverbot%2Fnode-mongodb-migrations/sbom","scorecard":{"id":681602,"data":{"date":"2025-08-11","repo":{"name":"github.com/neverbot/node-mongodb-migrations","commit":"7528ed7f12dd3c1a39d92b4bb4524062c362bc86"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'develop'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T23:21:48.330Z","repository_id":44663659,"created_at":"2025-08-21T23:21:48.331Z","updated_at":"2025-08-21T23:21:48.331Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32672563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["migrations","mongo","node","nodejs"],"created_at":"2025-05-12T19:38:14.319Z","updated_at":"2026-05-05T23:31:51.465Z","avatar_url":"https://github.com/neverbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-mongodb-migrations\n\n![npm](https://img.shields.io/npm/dt/node-mongodb-migrations)\n![npm](https://img.shields.io/npm/dw/node-mongodb-migrations)\n[![GitHub license](https://img.shields.io/github/license/neverbot/node-mongodb-migrations)](https://github.com/neverbot/node-mongodb-migrations/blob/master/LICENSE.md)\n![npm](https://img.shields.io/npm/v/node-mongodb-migrations)\n\n  Abstract migration framework for node.\n\n  Forked from [ikatun/node-migrate](https://github.com/ikatun/node-migrate), in turn forked from [tj/node-migrate](https://github.com/tj/node-migrate).\n\n  Can store migrations information both in a file or in a mongodb collection (useful for enviroments with multiple instanced servers).\n\n  Uses native mongodb promises (in the past it used [then-mongo](https://github.com/then/then-mongo) and before that [promised-mongo](https://github.com/gordonmleigh/promised-mongo) as promised-based mongo libraries).\n\n## Installation\n\n```shell-script\n$ npm install node-mongodb-migrations\n```\n\n## Usage\n\n```\nUsage: migrate [options] [command]\n\nOptions:\n\n   -c, --chdir \u003cpath\u003e      change the working directory\n   --state-file \u003cpath\u003e     set path to state file (migrations/.migrate)\n   --state-mongo \u003cformat\u003e  name of env variable containing the mongo connection string\n   --template-file \u003cpath\u003e  set path to template file to use for new migrations\n   --date-format \u003cformat\u003e  set a date format to use for new migration filenames\n\nNOTE: if both --state-mongo and --state-file options are specified while migrations collection is empty, the state file is migrated to the migrations collection before migration is initiated. If migrations collection contains migration state, state-file is ignored.\nThis behaviour can be used for seamless switching from https://github.com/tj/node-migrate (which at the time of this fork did not support persisting of state file to mongo collection).\n\nCommands:\n\n   down   [name]    migrate down till given migration\n   rollback         migrate down the last applied migration\n   up     [name]    migrate up till given migration (the default command)\n   create [title]   create a new migration file with optional [title]\n\n```\n\n## Programmatic usage\n\n```javascript\nvar migrate = require('node-mongodb-migrations');\nvar set = migrate.load('migration/.migrate', 'migration');\n\nset.up(function (err) {\n  if (err) throw err;\n\n  console.log('Migration completed');\n});\n```\n\n## Creating Migrations\n\nTo create a migration, execute `migrate create` with an optional title. `node-mongodb-migrationse` will create a node module within `./migrations/` which contains the following two exports:\n\n```javascript\nexports.up = function(next){\n  next();\n};\n\nexports.down = function(next){\n  next();\n};\n```\n\nAll you have to do is populate these, invoking `next()` when complete, and you are ready to migrate!\n\nFor example:\n\n    $ migrate create add-pets\n    $ migrate create add-owners\n\nThe first call creates `./migrations/{timestamp in milliseconds}-add-pets.js`, which we can populate:\n\n```javascript\nvar db = require('./db');\n\nexports.up = function(next){\n  db.rpush('pets', 'tobi');\n  db.rpush('pets', 'loki');\n  db.rpush('pets', 'jane', next);\n};\n\nexports.down = function(next){\n  db.rpop('pets');\n  db.rpop('pets');\n  db.rpop('pets', next);\n};\n```\n\nThe second creates `./migrations/{timestamp in milliseconds}-add-owners.js`, which we can populate:\n\n```javascript\nvar db = require('./db');\n\nexports.up = function(next){\n  db.rpush('owners', 'taylor');\n  db.rpush('owners', 'tj', next);\n};\n\nexports.down = function(next){\n  db.rpop('owners');\n  db.rpop('owners', next);\n};\n```\n\n## Running Migrations\n\nWhen first running the migrations, all will be executed in sequence.\n\n```shell-script\n$ migrate\nup : migrations/1316027432511-add-pets.js\nup : migrations/1316027432512-add-jane.js\nup : migrations/1316027432575-add-owners.js\nup : migrations/1316027433425-coolest-pet.js\nmigration : complete\n```\n\nSubsequent attempts will simply output \"complete\", as they have already been executed in this machine. `node-mongodb-migrations` knows this because it stores the current state in `./migrations/.migrate` which is typically a file that SCMs like GIT should ignore.\n\n```shell-script\n$ migrate\nmigration : complete\n```\n\nIf we were to create another migration using `migrate create`, and then execute migrations again, we would execute only those not previously executed:\n\n```shell-script\n$ migrate\nup : migrates/1316027433455-coolest-owner.js\n```\n\nYou can also run migrations incrementally by specifying a migration.\n\n```shell-script\n$ migrate up 1316027433425-coolest-pet.js\nup : migrations/1316027432511-add-pets.js\nup : migrations/1316027432512-add-jane.js\nup : migrations/1316027432575-add-owners.js\nup : migrations/1316027433425-coolest-pet.js\nmigration : complete\n```\n\nThis will run up-migrations upto (and including) `1316027433425-coolest-pet.js`. Similarly you can run down-migrations upto (and including) a specific migration, instead of migrating all the way down.\n\n```shell-script\n$ migrate down 1316027432512-add-jane.js\ndown : migrations/1316027432575-add-owners.js\ndown : migrations/1316027432512-add-jane.js\nmigration : complete\n```\n\n## API\n\n### `migrate.load(stateFile, migrationsDirectory)`\n\nReturns a `Set` populated with migration scripts from the `migrationsDirectory`\nand state loaded from `stateFile`.\n\n### `Set.up([migration, ]cb)`\n\nMigrates up to the specified `migration` or, if none is specified, to the latest\nmigration. Calls the callback `cb`, possibly with an error `err`, when done.\n\n### `Set.down([migration, ]cb)`\n\nMigrates down to the specified `migration` or, if none is specified, to the\nfirst migration. Calls the callback `cb`, possibly with an error `err`, when\ndone.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneverbot%2Fnode-mongodb-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneverbot%2Fnode-mongodb-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneverbot%2Fnode-mongodb-migrations/lists"}