title: CQRS - how to handle new report tables (or: how to import ALL history from the event store)
body: <p>I've studied some CQRS sample implementations (Java / .Net) which use event sourcing as the event store and a simple (No)SQL stores as the 'report store'.</p>
  
  <p>Looks all good, but I seem to be missing something in all sample implementations.</p>
  
  <p>How to handle the addition of new report stores / screens, after an application has gone in production? and how to import existing (latest) data from the event store to the new report store? </p>
  
  <p>Ie:</p>
  
  <p>Imagine a basic DDD/CQRS driven CRM application. 
  Every screen (view really) has it's own structured report store (a SQL table). 
  All these views get updated using handlers listening to the domain events (CustomerCreated / CustomerHasMoved, etc).</p>
  
  <p>One feature of the CRM is that it can log phone calls (PhoneCallLogged event). Due to time constraints we only implemented the logging of phone calls in V1 of the CRM (viewing and reporting of who handled which phone call will be implemented in V2)</p>
  
  <p>After a time running in production, we want to implement the 'reporting' of logged phone calls per customer and sales representative.</p>
  
  <p>So we need to add some screens (views) and the supporting report tables (in the report store) and fill it with the data already collected in the Event Store...</p>
  
  <p>That is where I get stuck while looking at the samples I studied. They don't handle the import of existing (history) data from the event store to a (new) report store.</p>
  
  <p>All samples of the EventRepository (DomainRepository) only have a method 'GetById' and 'Add', they don't support getting ALL aggregate roots in once to fill a new report table.</p>
  
  <p>Without this initial data import, the new screens are only updated for newly occurred events. Not for the phone calls already logged (because there was no report listener for the PhoneCallLogged event)</p>
  
  <p>Any suggestions, recommendations ?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Remco</p>