Example #1
0
 public BatchOperation(IStoreBatchProgress store, MigrationConfig config)
 {
     _store     = store;
     _config    = config;
     _processed = _store.StartOrContinue(config.Name);
     EventStore.Logger.Debug($"'{config.Name}' [migration] starts/resumes after {_processed.Value} commits");
 }
Example #2
0
        public void MigrateEventsTo(IStoreEvents newStorage, string name, Action <IConfigMigration> config = null)
        {
            name.MustNotBeEmpty();
            var conf = new MigrationConfig(name);

            config?.Invoke(conf);
            var l = EventStore.Logger;

            var rew = new EventsRewriter(conf.Converters, _settings.EventMappers);

            l.Debug("Starting store migration with batch operation: {name}", name);
            using (var operation = new BatchOperation(_store, conf))
            {
                Optional <Commit> commit;
                do
                {
                    commit = operation.GetNextCommit();
                    if (commit.HasValue)
                    {
                        l.Debug("Importing commit {commit}", commit.Value.CommitId);
                        newStorage.Advanced.ImportCommit(rew.Rewrite(commit.Value));
                    }
                } while (commit.HasValue);
            }
            l.Debug("Migration {name} completed", name);
        }