{"id":14956733,"url":"https://github.com/rebus-org/mongrow","last_synced_at":"2025-10-24T10:30:56.225Z","repository":{"id":138117594,"uuid":"166376089","full_name":"rebus-org/Mongrow","owner":"rebus-org","description":":herb: MongoDB migration library","archived":false,"fork":false,"pushed_at":"2024-10-23T17:42:20.000Z","size":4896,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-29T09:44:56.707Z","etag":null,"topics":["evolutionary-database-design","migrate-database","migration","migration-tool","migrations","migrator","mongo","mongodb","mongodb-database"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rebus-org.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2019-01-18T09:04:51.000Z","updated_at":"2024-10-23T17:42:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"34af7ac7-c0fa-4e85-a9c6-cc44ff0d8b8e","html_url":"https://github.com/rebus-org/Mongrow","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongrow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongrow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongrow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongrow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rebus-org","download_url":"https://codeload.github.com/rebus-org/Mongrow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237950813,"owners_count":19392666,"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":["evolutionary-database-design","migrate-database","migration","migration-tool","migrations","migrator","mongo","mongodb","mongodb-database"],"created_at":"2024-09-24T13:13:24.966Z","updated_at":"2025-10-24T10:30:55.137Z","avatar_url":"https://github.com/rebus-org.png","language":"C#","readme":"# Mongrow\n\nIt's a MongoDB migration helper.\n\nWith this, you can write classes that implement steps to migrate a MongoDB database.\n\n## What do steps look like?\n\nLike this:\n\n```csharp\n[Step(1)]\npublic class AddAdminUser : IStep\n{\n    public async Task Execute(IMongoDatabase database)\n    {\n        var users = database.GetCollection\u003cBsonDocument\u003e(\"users\");\n\n        var adminUser = new\n        {\n            _id = Guid.NewGuid().ToString(),\n            uid = \"user1\",\n            claims = new[]\n            {\n                new {type = ClaimTypes.Email, value = \"admin@whatever.com\"},\n                new {type = ClaimTypes.Role, value = \"admin\"},\n            }\n        };\n\n        await users.InsertOneAsync(adminUser.ToBsonDocument());\n    }\n}\n```\n\nand then you execute it like this:\n\n```csharp\nvar migrator = new Migrator(\n    connectionString: \"mongodb://mongohost01/MyDatabase\",\n    steps: GetSteps.FromAssemblyOf\u003cAddAdminUser\u003e()\n);\n\nmigrator.Execute();\n```\n\n## How to make robust steps\n\nWhile steps are just C# code, and you can do anything you want in there to the passed-in `IMongoDatabase`, you are\nencouraged to write steps that do not change along with the rest of your code.\n\nThis means that you most likely want to use `BsonDocument`, magic strings, and anonymous types throughout.\n\nWouldn't want a rename of one of your C# classes to mess up how all of your existing migrations work.\n\n## Parallel execution\n\nA distributed lock is used to coordinate execution, so Mongrow will never execute migrations concurrently.\n\n\n\n## How to number the steps\n\nSteps are identified by a number and a \"branch specification\". The branch specification allows for\nco-existence of steps with the same number, thus escaping a global lock on the number sequence when\nworking with multiple branches.\n\nThe branch specification defaults to `master`. You are encouraged to structure your steps like this:\n\n```\n| 1 - master |                 |\n| 2 - master |                 |\n| 3 - master | 3 - some-branch |\n|            | 4 - some-branch |\n| 5 - master |                 |\n```\n\nand so forth.\n\nPLEASE NOTE: You are not allowed to INSERT a step into the sequence, so if step number `n` with any branch\nspecification has been executed, you will get an exception if you add a migration with number `\u003c n` for\nthat branch specification.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebus-org%2Fmongrow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frebus-org%2Fmongrow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebus-org%2Fmongrow/lists"}