{"id":22350652,"url":"https://github.com/timmoth/docmigrator","last_synced_at":"2025-07-30T06:32:04.851Z","repository":{"id":246251900,"uuid":"820511915","full_name":"Timmoth/DocMigrator","owner":"Timmoth","description":"Zero downtime on-the-fly document migrations.","archived":false,"fork":false,"pushed_at":"2024-06-26T16:07:21.000Z","size":2766,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T03:54:57.807Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Timmoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"docs/support.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-26T16:02:55.000Z","updated_at":"2024-06-30T13:08:31.000Z","dependencies_parsed_at":"2024-06-26T22:06:22.476Z","dependency_job_id":null,"html_url":"https://github.com/Timmoth/DocMigrator","commit_stats":null,"previous_names":["timmoth/docmigrator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Timmoth/DocMigrator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FDocMigrator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FDocMigrator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FDocMigrator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FDocMigrator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Timmoth","download_url":"https://codeload.github.com/Timmoth/DocMigrator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FDocMigrator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267822490,"owners_count":24149629,"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-30T02:00:09.044Z","response_time":70,"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-04T11:12:40.866Z","updated_at":"2025-07-30T06:32:04.618Z","avatar_url":"https://github.com/Timmoth.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DocMigrator ![Logo](/logo.png)\n[![Json](https://img.shields.io/nuget/v/DocMigrator.Json?label=Json)](https://www.nuget.org/packages/DocMigrator.Json)\n[![Bson](https://img.shields.io/nuget/v/DocMigrator.Bson?label=Bson)](https://www.nuget.org/packages/DocMigrator.Bson)\n\nZero downtime on-the-fly document migrations.\n\n### Overview:\nWhen working with a document database, it's common to store multiple document schemas simultaneously. Often, this is fine since you can develop your application code to be backward compatible with previous versions. However, sometimes writing backward-compatible code can become very messy and error prone, especially when dealing with many versions of a document.\n\nAn alternative solution is to apply a migration to the entire database at once, though this is not optimal since it can lead to downtime and performance issues during the migration. Enter DocMigrator, a simple yet high-performance package that enables you to migrate your documents on the fly as they are being deserialized, ensuring zero downtime.\n## Find out more 🤔\n  - [Overview ✅](https://timmoth.github.io/DocMigrator/index)\n  - [Releases 📒](https://timmoth.github.io/DocMigrator/releases)\n  - [Support 🛟](https://timmoth.github.io/DocMigrator/support)\n  - [Contributing 🙏](https://timmoth.github.io/DocMigrator/contributing)\n\n### Bson Demo\n```csharp\n// Install the nuget package\ndotnet add package DocMigrator.Bson\n\n// Define document\npublic class User\n{\n    [BsonElement(\"schema_version\")] public int SchemaVersion { get; set; }\n    [BsonElement(\"full_name\")] public string FullName { get; set; }\n    [BsonElement(\"avatar_url\")] public string AvatarUrl { get; set; }\n}\n\n// Create Migrators\npublic class UserMigrationDeserializer : BsonMigrationDeserializer\u003cUser\u003e\n{\n    public UserMigrationDeserializer(IServiceProvider serviceProvider,\n        ILogger\u003cUserMigrationDeserializer\u003e logger) :\n        base(serviceProvider, logger, new List\u003cFunc\u003cIServiceProvider, BsonDocument, ValueTask\u003e\u003e\n        {\n            ApplyMigration_1,\n            ApplyMigration_2\n        })\n    {\n    }\n\n    public static ValueTask ApplyMigration_1(IServiceProvider serviceProvider, BsonDocument document)\n    {\n        document[\"full_name\"] = $\"{document[\"first_name\"]} {document[\"last_name\"]}\";\n        document.Remove(\"first_name\");\n        document.Remove(\"last_name\");\n        return ValueTask.CompletedTask;\n    }\n\n    public static async ValueTask ApplyMigration_2(IServiceProvider serviceProvider, BsonDocument document)\n    {\n        var avatarService = serviceProvider.GetRequiredService\u003cAvatarService\u003e();\n        document[\"avatar_url\"] = await avatarService.GetAvatarUrl(document[\"id\"]);\n    }\n}\n\n// Register your migrators\nservices.AddBsonMigrator(Assembly.GetExecutingAssembly());\n\n```\n\n### Json Demo\n```csharp\n// Install the nuget package\ndotnet add package DocMigrator.Json\n\n// Define document\npublic class User\n{\n    [JsonPropertyName(\"schema_version\")] public int SchemaVersion { get; set; }\n    [JsonPropertyName(\"full_name\")] public string FullName { get; set; }\n    [JsonPropertyName(\"avatar_url\")] public string AvatarUrl { get; set; }\n}\n\n// Create Migrators\npublic class UserMigrationDeserializer : JsonMigrationDeserializer\u003cUser\u003e\n{\n    public UserMigrationDeserializer(IServiceProvider serviceProvider,\n        ILogger\u003cUserMigrationDeserializer\u003e logger) :\n        base(serviceProvider, logger, new List\u003cFunc\u003cIServiceProvider, JsonObject, ValueTask\u003e\u003e\n        {\n            ApplyMigration_1,\n            ApplyMigration_2\n        })\n    {\n    }\n\n    public static ValueTask ApplyMigration_1(IServiceProvider serviceProvider, JsonObject document)\n    {\n        document[\"full_name\"] = $\"{document[\"first_name\"]} {document[\"last_name\"]}\";\n        return ValueTask.CompletedTask;\n    }\n\n    public static async ValueTask ApplyMigration_2(IServiceProvider serviceProvider, JsonObject document)\n    {\n        var avatarService = serviceProvider.GetRequiredService\u003cAvatarService\u003e();\n        document[\"avatar_url\"] = await avatarService.GetAvatarUrl(document[\"id\"]);\n    }\n}\n\n// Register your migrators\nservices.AddJsonMigrator(Assembly.GetExecutingAssembly());\n\n```\n\n## Collaboration 🙏\nLike the idea and want to get involved? Check out the open issues or shoot me a message if you've got any ideas / feedback!\n\n## Support 🛟\nNeed help? Ping me on [linkedin](https://www.linkedin.com/in/timmoth/) and I'd be more then happy to jump on a call to debug, help configure or answer any questions.\n\n## Support the project 🤝\n\n- **🌟 Star this repository**: It means a lot to me and helps with exposure.\n- **🪲 Report bugs**: Report any bugs you find by creating an issue.\n- **📝 Contribute**: Read the [contribution guide](https://timmoth.github.io/DocMigrator/contributing) then pick up or create an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimmoth%2Fdocmigrator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimmoth%2Fdocmigrator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimmoth%2Fdocmigrator/lists"}