diff --git a/Mongo.Migration.Test.Core/Mongo.Migration.Test.Core.csproj b/Mongo.Migration.Test.Core/Mongo.Migration.Test.Core.csproj
index eeeb584..3c8289f 100644
--- a/Mongo.Migration.Test.Core/Mongo.Migration.Test.Core.csproj
+++ b/Mongo.Migration.Test.Core/Mongo.Migration.Test.Core.csproj
@@ -2,8 +2,7 @@
false
Library
- net5.0;netcoreapp3.1
- 9.0
+ net6.0
@@ -21,9 +20,9 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Mongo.Migration/Mongo.Migration.csproj b/Mongo.Migration/Mongo.Migration.csproj
index b0c11cf..8120e77 100644
--- a/Mongo.Migration/Mongo.Migration.csproj
+++ b/Mongo.Migration/Mongo.Migration.csproj
@@ -1,30 +1,25 @@
-
+
Mongo.Migration
Mongo.Migration
3.1.4
3.1.4
- net5.0;netcoreapp3.1
- 9.0
+ net6.0
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Mongo.Migration/MongoMigration.cs b/Mongo.Migration/MongoMigration.cs
index 38cbe50..64979b4 100644
--- a/Mongo.Migration/MongoMigration.cs
+++ b/Mongo.Migration/MongoMigration.cs
@@ -1,7 +1,8 @@
-using Mongo.Migration.Documents.Locators;
+using Mongo.Migration.Documents.Locators;
using Mongo.Migration.Migrations.Document;
using Mongo.Migration.Migrations.Locators;
using Mongo.Migration.Services;
+using Mongo.Migration.Startup;
namespace Mongo.Migration
{
@@ -13,6 +14,7 @@ internal class MongoMigration : IMongoMigration
private readonly IDatabaseTypeMigrationDependencyLocator _databaseMigrationLocator;
private readonly IMigrationService _migrationService;
private readonly IRuntimeVersionLocator _runtimeVersionLocator;
+ private readonly IMongoMigrationSettings _settings;
public MongoMigration(
IMigrationLocator documentMigrationLocator,
@@ -20,7 +22,8 @@ public MongoMigration(
IRuntimeVersionLocator runtimeVersionLocator,
ICollectionLocator collectionLocator,
IStartUpVersionLocator startUpVersionLocator,
- IMigrationService migrationService)
+ IMigrationService migrationService,
+ IMongoMigrationSettings settings)
{
_documentMigrationLocator = documentMigrationLocator;
_databaseMigrationLocator = databaseMigrationLocator;
@@ -28,14 +31,22 @@ public MongoMigration(
_collectionLocator = collectionLocator;
_startUpVersionLocator = startUpVersionLocator;
_migrationService = migrationService;
+ _settings = settings;
}
public void Run()
{
- _documentMigrationLocator.Locate();
+ if (!_settings.SkipDocumentMigration)
+ {
+ _documentMigrationLocator.Locate();
+ }
_databaseMigrationLocator.Locate();
_runtimeVersionLocator.Locate();
- _collectionLocator.Locate();
+ if(!_settings.SkipDocumentMigration)
+ {
+ _collectionLocator.Locate();
+ }
+
_startUpVersionLocator.Locate();
_migrationService.Migrate();
diff --git a/Mongo.Migration/Services/MigrationService.cs b/Mongo.Migration/Services/MigrationService.cs
index d925805..9f62538 100644
--- a/Mongo.Migration/Services/MigrationService.cs
+++ b/Mongo.Migration/Services/MigrationService.cs
@@ -4,6 +4,7 @@
using Mongo.Migration.Migrations.Database;
using Mongo.Migration.Migrations.Document;
using Mongo.Migration.Services.Interceptors;
+using Mongo.Migration.Startup;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
@@ -16,10 +17,11 @@ internal class MigrationService : IMigrationService
private readonly IStartUpDatabaseMigrationRunner _startUpDatabaseMigrationRunner;
private readonly IMigrationInterceptorProvider _provider;
private readonly DocumentVersionSerializer _serializer;
+ private readonly IMongoMigrationSettings _settings;
public MigrationService(DocumentVersionSerializer serializer, IMigrationInterceptorProvider provider,
- IStartUpDocumentMigrationRunner startUpDocumentMigrationRunner, IStartUpDatabaseMigrationRunner startUpDatabaseMigrationRunner)
- : this(serializer, provider, NullLoggerFactory.Instance)
+ IStartUpDocumentMigrationRunner startUpDocumentMigrationRunner, IStartUpDatabaseMigrationRunner startUpDatabaseMigrationRunner, IMongoMigrationSettings settings)
+ : this(serializer, provider, NullLoggerFactory.Instance, settings)
{
_startUpDocumentMigrationRunner = startUpDocumentMigrationRunner;
_startUpDatabaseMigrationRunner = startUpDatabaseMigrationRunner;
@@ -28,11 +30,13 @@ public MigrationService(DocumentVersionSerializer serializer, IMigrationIntercep
private MigrationService(
DocumentVersionSerializer serializer,
IMigrationInterceptorProvider provider,
- ILoggerFactory loggerFactory)
+ ILoggerFactory loggerFactory,
+ IMongoMigrationSettings settings)
{
_serializer = serializer;
_provider = provider;
_logger = loggerFactory.CreateLogger();
+ _settings = settings;
}
public void Migrate()
@@ -46,7 +50,10 @@ public void Migrate()
private void OnStartup()
{
_startUpDatabaseMigrationRunner.RunAll();
- _startUpDocumentMigrationRunner.RunAll();
+ if (!_settings.SkipDocumentMigration)
+ {
+ _startUpDocumentMigrationRunner.RunAll();
+ }
}
private void RegisterSerializer()
diff --git a/Mongo.Migration/Startup/IMongoMigrationSettings.cs b/Mongo.Migration/Startup/IMongoMigrationSettings.cs
index 07f2aaf..ed9864f 100644
--- a/Mongo.Migration/Startup/IMongoMigrationSettings.cs
+++ b/Mongo.Migration/Startup/IMongoMigrationSettings.cs
@@ -10,5 +10,6 @@ public interface IMongoMigrationSettings
DocumentVersion DatabaseMigrationVersion { get; set; }
string VersionFieldName { get; set; }
MongoClientSettings ClientSettings { get; set; }
+ public bool SkipDocumentMigration { get; set; }
}
}
\ No newline at end of file
diff --git a/Mongo.Migration/Startup/MongoMigrationSettings.cs b/Mongo.Migration/Startup/MongoMigrationSettings.cs
index 25def9f..6fddab9 100644
--- a/Mongo.Migration/Startup/MongoMigrationSettings.cs
+++ b/Mongo.Migration/Startup/MongoMigrationSettings.cs
@@ -14,5 +14,7 @@ public class MongoMigrationSettings : IMongoMigrationSettings
public string VersionFieldName { get; set; }
public MongoClientSettings ClientSettings { get; set; }
+
+ public bool SkipDocumentMigration { get; set; } = true;
}
}
\ No newline at end of file