Exemplo n.º 1
0
 protected AbstractMigrator(MigratorOptions options)
 {
     MigrationStateKey = options.MigrationStateKey;
     ServerUrl         = options.ServerUrl;
     DatabaseName      = options.DatabaseName;
     HttpClient        = options.HttpClient;
     OperateOnTypes    = options.OperateOnTypes;
     RemoveAnalyzers   = options.RemoveAnalyzers;
     ImportRavenFs     = options.ImportRavenFs;
     Result            = options.Result;
     OnProgress        = options.OnProgress;
     Database          = options.Database;
     CancelToken       = options.CancelToken;
 }
Exemplo n.º 2
0
 protected AbstractMigrator(MigratorOptions options)
 {
     MigrationStateKey = options.MigrationStateKey;
     ServerUrl         = options.ServerUrl;
     DatabaseName      = options.DatabaseName;
     HttpClient        = options.HttpClient;
     ApiKey            = options.ApiKey;
     EnableBasicAuthenticationOverUnsecuredHttp = options.EnableBasicAuthenticationOverUnsecuredHttp;
     SkipServerCertificateValidation            = options.SkipServerCertificateValidation;
     OperateOnTypes  = options.OperateOnTypes;
     RemoveAnalyzers = options.RemoveAnalyzers;
     ImportRavenFs   = options.ImportRavenFs;
     Result          = options.Result;
     OnProgress      = options.OnProgress;
     Database        = options.Database;
     CancelToken     = options.CancelToken;
 }
Exemplo n.º 3
0
 public Migrator_V3(MigratorOptions options, MigratorParameters parameters, MajorVersion majorVersion, int buildVersion) : base(options, parameters)
 {
     _majorVersion = majorVersion;
     _buildVersion = buildVersion;
 }
Exemplo n.º 4
0
 public Migrator_V2(MigratorOptions options, MigratorParameters parameters) : base(options, parameters)
 {
 }
Exemplo n.º 5
0
 public Importer(MigratorOptions options, MigratorParameters parameters, int buildVersion) : base(options, parameters)
 {
     _buildVersion = buildVersion;
 }
Exemplo n.º 6
0
 public Migrator_V2(DocumentDatabase database, MigratorOptions options) : base(database, options)
 {
 }
Exemplo n.º 7
0
 protected AbstractLegacyMigrator(DocumentDatabase database, MigratorOptions options) : base(options)
 {
     _database = database;
 }
Exemplo n.º 8
0
        public long StartMigratingSingleDatabase(DatabaseMigrationSettings databaseMigrationSettings, DocumentDatabase database)
        {
            var operationId = database.Operations.GetNextOperationId();
            var cancelToken = new OperationCancelToken(database.DatabaseShutdown);
            var result      = new SmugglerResult();

            var databaseName = databaseMigrationSettings.DatabaseName;

            database.Operations.AddOperation(null,
                                             $"Database name: '{databaseName}' from url: {_serverUrl}",
                                             Operations.OperationType.DatabaseMigrationRavenDb,
                                             taskFactory: onProgress => Task.Run(async() =>
            {
                onProgress?.Invoke(result.Progress);

                var message = $"Importing from RavenDB {EnumHelper.GetDescription(_buildMajorVersion)}";

                result.AddInfo(message);

                using (cancelToken)
                {
                    try
                    {
                        var migrationStateKey = $"{MigrationStateKeyBase}" +
                                                $"{EnumHelper.GetDescription(_buildMajorVersion)}/" +
                                                $"{databaseName}/" +
                                                $"{_serverUrl}";

                        var options = new MigratorOptions
                        {
                            MigrationStateKey = migrationStateKey,
                            ServerUrl         = _serverUrl,
                            DatabaseName      = databaseName,
                            ApiKey            = _apiKey,
                            TransformScript   = databaseMigrationSettings.TransformScript,
                            EnableBasicAuthenticationOverUnsecuredHttp = _enableBasicAuthenticationOverUnsecuredHttp,
                            SkipServerCertificateValidation            = _skipServerCertificateValidation,
                            RemoveAnalyzers = databaseMigrationSettings.RemoveAnalyzers,
                            ImportRavenFs   = databaseMigrationSettings.ImportRavenFs,
                            OperateOnTypes  = databaseMigrationSettings.OperateOnTypes,
                            OperateOnDatabaseRecordTypes = databaseMigrationSettings.OperateOnDatabaseRecordTypes
                        };

                        var parameters = new MigratorParameters
                        {
                            HttpClient  = _httpClient,
                            Result      = result,
                            OnProgress  = onProgress,
                            Database    = database,
                            CancelToken = cancelToken
                        };

                        AbstractMigrator migrator;
                        switch (_buildMajorVersion)
                        {
                        case MajorVersion.V2:
                            migrator = new Migrator_V2(options, parameters);
                            break;

                        case MajorVersion.V30:
                        case MajorVersion.V35:
                            migrator = new Migrator_V3(options, parameters, _buildMajorVersion, _buildVersion);
                            break;

                        case MajorVersion.V4:
                            migrator = new Importer(options, parameters, _buildVersion);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException(nameof(_buildMajorVersion), _buildMajorVersion, null);
                        }

                        await migrator.Execute();
                    }
                    catch (Exception e)
                    {
                        result.AddError($"Error occurred during database migration named: {databaseName}." +
                                        $"Exception: {e.Message}");

                        throw;
                    }
                }

                return((IOperationResult)result);
            }, cancelToken.Token), id: operationId, token: cancelToken);

            return(operationId);
        }
Exemplo n.º 9
0
 protected AbstractLegacyMigrator(MigratorOptions options, MigratorParameters parameters) : base(options, parameters)
 {
 }
Exemplo n.º 10
0
 public Importer(MigratorOptions options) : base(options)
 {
 }
Exemplo n.º 11
0
 public Migrator_V3(DocumentDatabase database, MigratorOptions options, MajorVersion majorVersion, int buildVersion) : base(database, options)
 {
     _majorVersion = majorVersion;
     _buildVersion = buildVersion;
 }
Exemplo n.º 12
0
 protected AbstractMigrator(MigratorOptions options, MigratorParameters parameters)
 {
     Options    = options;
     Parameters = parameters;
 }