{"id":22048537,"url":"https://github.com/samhammerag/migrate-mongo-sag","last_synced_at":"2026-03-04T23:31:27.797Z","repository":{"id":242530608,"uuid":"809802876","full_name":"SamhammerAG/migrate-mongo-sag","owner":"SamhammerAG","description":"A database migration tool for MongoDB in Node","archived":false,"fork":false,"pushed_at":"2026-02-16T16:03:34.000Z","size":924,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-16T21:57:15.954Z","etag":null,"topics":["js-lib","migrations","mongodb"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/SamhammerAG.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-03T13:31:17.000Z","updated_at":"2026-02-16T15:58:40.000Z","dependencies_parsed_at":"2026-02-16T16:02:52.449Z","dependency_job_id":null,"html_url":"https://github.com/SamhammerAG/migrate-mongo-sag","commit_stats":null,"previous_names":["samhammerag/migrate-mongo-sag"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/SamhammerAG/migrate-mongo-sag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamhammerAG%2Fmigrate-mongo-sag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamhammerAG%2Fmigrate-mongo-sag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamhammerAG%2Fmigrate-mongo-sag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamhammerAG%2Fmigrate-mongo-sag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamhammerAG","download_url":"https://codeload.github.com/SamhammerAG/migrate-mongo-sag/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamhammerAG%2Fmigrate-mongo-sag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30099346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T23:31:22.529Z","status":"ssl_error","status_checked_at":"2026-03-04T23:31:22.112Z","response_time":59,"last_error":"SSL_read: 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":["js-lib","migrations","mongodb"],"created_at":"2024-11-30T14:12:42.868Z","updated_at":"2026-03-04T23:31:27.776Z","avatar_url":"https://github.com/SamhammerAG.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# migrate-mongo-sag\n\nmigrate-mongo-sag is a database migration tool for MongoDB running in Node.js\u003cbr\u003e\nit provides some additional functionality to the original migrate-mongo https://github.com/seppevs/migrate-mongo\n\nthis tool additionally supports:\n\n-   execution of migration-scripts for \"brand\" and \"default\" (will be merged)\n-   new options to set \"brand\", \"env\" and \"app\" as environment variables\n-   new command \"dropDatabase\" to delete the configured database\n-   load settings from .env files by https://github.com/motdotla/dotenv\n-   load vault secrets defined in .env files https://github.com/SamhammerAG/vault-client-sag\n\n## Requirements\n\n-   yarn 4.x\n-   node 18.x\n\n## Installation\n\n`$ yarn add @samhammer/migrate-mongo-sag`\n\n## CLI Usage\n\n```\n$ yarn run migrate-mongo\nUsage: migrate-mongo [options] [command]\n\nCLI to migrate mongodb\n\nOptions:\n  -V, --version                   output the version number\n  -e, --env \u003cenv\u003e                 set process.env.Environment\n  -b, --brand \u003cbrand\u003e             set process.env.Brand\n  -a, --app \u003capp\u003e                 set process.env.App\n  -t, --trace                     set process.env.TRACE to enable trace outputs\n  -h, --help                      display help for command\n\nCommands:\n  create [options] [description]  create a new database migration with the provided description\n  up                              run all pending database migrations\n  down                            undo the last applied database migration\n  status                          print the changelog of the database\n  dropDatabase                    deletes the database\n  help [command]                  display help for command\n```\n\n## Basic Setup\n\n-   create a \".env\" file and \".env.local\" (optional) file\n-   create a \"migrate-mongo.config.js\" file\n-   create a \"migrations\" directory\n    -   create sub-directory \"default\"\n    -   create sub-directory per \"brand\"\n    -   place a sample-migration.js in \"default\" and \"brand\" directories (optional)\n\n#### sample .env\n\nthis should be used to define settings for all environments and secret keys\n\n```\n#setup directory name for default migrations (mandatory)\nDefaultMigrationsDir=\"default\"\n\n#setup vault secret for user name + password (optional)\nMongoDbOptions__AdminUserName=\"VaultKey--kv-v2/data/mongodb/Username\"\nMongoDbOptions__AdminPassword=\"VaultKey--kv-v2/data/mongodb/Password\"\n\n#setup url for mongodb which can then be used in migrate-mongo-config.js (optional)\nMongoDb__Url=\"mongodb://$MongoDbOptions__AdminUserName:$MongoDbOptions__AdminPassword@$MongoDbOptions__DatabaseHost\"\n```\n\n#### sample .env.local\n\nthis should be used to define settings for local development only\n\n```\n#setup host for mongodb to be used as placeholder in mongodb url (optional)\nMongoDbOptions__DatabaseHost=\"localhost:27017\"\n\n#setup defaults for environment and brand; can still be overwritten by cli with \"--env\" and \"--brand\" (optional)\nEnvironment=dev\nBrand=myBrand\n\n#setup logs for processes\nLogger_LogFile=\u003cLog file path, default is logs/log.json\u003e\nLogger_LogLevel=\u003cLog level default is \"info\"\u003e\nLogger_ClientUrl=\u003celastic log url. Unset if no use\u003e\nLogger_ClientUsername=\u003cusername\u003e\nLogger_ClientPassword=\u003cpassword\u003e\nLogger_ClientIndex=\u003cexpected index\u003e\n```\n\n#### sample migrate-mongo.config.js\n\nwith this config we can map settings defined in environment for migrate-mongo\u003cbr\u003e\nwe can access settings defined in environment variables or .env files by process.env\n\n```js\n/** @type {import(\"migrate-mongo\").config.Config} */\nmodule.exports = {\n    mongodb: {\n        // Change (or review) the url to your MongoDB:\n        url: `${process.env.MongoDb__Url}`,\n\n        // Change this to your database name\n        databaseName: \"my-database\"\n    },\n\n    // The migrations dir, can be an relative or absolute path. Only edit this when really necessary.\n    migrationsDir: \"migrations\",\n\n    // The mongodb collection where the applied changes are stored. Only edit this when really necessary.\n    changelogCollectionName: \"migrations\",\n\n    // The file extension to create migrations and search for in migration dir\n    migrationFileExtension: \".js\",\n\n    // Enable the algorithm to create a checksum of the file contents and use that in the comparison to determine\n    // if the file should be run.  Requires that scripts are coded to be run multiple times.\n    useFileHash: false,\n\n    // Change moduleSystem for migration files. Supported values are \"commonjs\" and \"esm\".\n    moduleSystem: \"commonjs\"\n};\n```\n\n## How to publish\n\n-   Create \u0026 Push a tag with new version number\n-   The CICD actions will take this version number for npm package automatically\n-   Check github action to validated, that package was released to npm registry.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamhammerag%2Fmigrate-mongo-sag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamhammerag%2Fmigrate-mongo-sag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamhammerag%2Fmigrate-mongo-sag/lists"}