{"id":22218581,"url":"https://github.com/megahertz/mongoomig","last_synced_at":"2025-07-27T14:32:51.472Z","repository":{"id":57301911,"uuid":"103298698","full_name":"megahertz/mongoomig","owner":"megahertz","description":"Yet another mongoose migration tool","archived":false,"fork":false,"pushed_at":"2019-04-10T16:44:30.000Z","size":31,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-19T11:02:03.867Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/megahertz.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":"2017-09-12T17:03:13.000Z","updated_at":"2023-03-17T12:09:12.000Z","dependencies_parsed_at":"2022-09-11T07:11:12.436Z","dependency_job_id":null,"html_url":"https://github.com/megahertz/mongoomig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/megahertz/mongoomig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fmongoomig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fmongoomig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fmongoomig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fmongoomig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/megahertz","download_url":"https://codeload.github.com/megahertz/mongoomig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fmongoomig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267370653,"owners_count":24076464,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-02T22:27:11.344Z","updated_at":"2025-07-27T14:32:51.109Z","avatar_url":"https://github.com/megahertz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoomig\n[![Build Status](https://travis-ci.org/megahertz/mongoomig.svg?branch=master)](https://travis-ci.org/megahertz/mongoomig)\n[![npm version](https://badge.fury.io/js/mongoomig.svg)](https://badge.fury.io/js/mongoomig)\n[![Dependencies status](https://david-dm.org/megahertz/mongoomig/status.svg)](https://david-dm.org/megahertz/mongoomig)\n\n## Description\n\nYet another mongoose migration tool\n\n### Key features\n\n - Async/await is default concept\n - Mongoose 4.11 support without deprecation warning\n - Could be configured through command line arguments, environment\n variables or config file\n - No dependencies, just one peer dependency - mongoose\n - Typescript support\n\n## Installation\n\nInstall with [npm](https://npmjs.org/package/mongoomig):\n\n    $ npm install mongoomig\n\n## Usage\n\n1. Create a migration. The following command creates a new migration\n    file ./migrations/${date}-first-migration.js\n\n    $ mongoomig create first-migration\n\n2. Write migration code\n\n    ```js\n    'use strict';\n\n    const User = require('../models/User');\n\n    module.exports = {\n      async up() {\n        await User.create({ name: 'test-user' });\n      },\n\n      async down() {\n        await User.deleteOne({ name: 'test-user' });\n      },\n    };\n    ```\n\n3. Execute the migration\n\n    $ mongoomig up\n\n4. (Optional) Add the migration command to package.json script:\n\n```\n\"scripts\": {\n  \"start\": \"node index.js\",\n  \"migrate\": \"mongoomig up\"\n}\n```\n\nAlso, you can check [the example](example/migrations).\n\n### With Typescript\n\nYou can compile your modules before migration, or use ts-node instead:\n```bash\nnpm install -D ts-node\nmongomig up --require ts-node/register\n```\n\n## Options\n\n### Command line\n\n```sh\nUsage: mongoomig [options] \u003ccommand\u003e\n\nCommands:\n  up [name]       Migrate up till given migration\n  down [name]     Migrate down till given migration\n  create \u003cname\u003e   Create a new migration\n  list            Show migrations which are applied\n\nOptions:\n  -c, --config=\u003cpath\u003e      Load config from json or js file, default to\n                             ./migrations/config.js\n  -u, --url=\u003curl\u003e          Mongodb connection string\n  --collection=\u003cname\u003e      Migrations collection, defaults to migrations\n  -p, --path=\u003cpath\u003e        Where your migrations are stored, defaults to\n                             ./migrations\n  --reconnectInterval=\u003cms\u003e Try to reconnect every \u003cms\u003e, default 300\n  --reconnectTries=\u003ccount\u003e Try to reconnect \u003ccount\u003e times, default 100\n  -r, --require=\u003cmodule\u003e   Require a module before loading migrations\n  -s, --silent             Silent mode, defaults to false\n  -d, --debug              Debug mode, defaults to false\n```\n\n### Environment variables\n\nAlso, you can set a such options through environment variable. Just\nset MONGOOMIG_\u003cOPTION_NAME_UPPERCASED\u003e. For example,\nthe MONGOOMIG_COLLECTION environment variable is equal to the collection\noption.\n\nAdditionally, mongoomig tries to load the url option from the MONGO_URL\nenvironment variable if another ways are not available.\n\n### Config file\n\nAnother way is to specify options inside a config. By default,\nthis package tries to read a config from migrations/config.js. Here is\nthe example of such a config:\n\n```js\n'use strict';\n\nmodule.exports = {\n  url: 'mongodb://localhost/tiny-blog',\n};\n```\n\n## API\n\nIf you would like to run migrations from your code instead of command\nline, you can use API.\n\n```js\nconst Migration = require('mongoomig/lib/Migration');\n\nconst migration = new Migration({ path, url });\nawait migration.connect();\nawait migration.up();\n```\n\nA good example is [index.js](index.js) of this package.\n\n## License\n\nLicensed under MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegahertz%2Fmongoomig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegahertz%2Fmongoomig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegahertz%2Fmongoomig/lists"}