title: How to migrate serialized exchange of a JdbcAggregationRepository?
body: <p>I have an Apache Camel application, which uses an <a href="https://camel.apache.org/components/3.4.x/eips/aggregate-eip.html" rel="nofollow noreferrer">Aggregator</a> with a persistent aggregation repository. Sometimes my message model changes and I have to handle it.</p>
  <p>Unfortunately the exchange isn't saved as JSON, XML or text, it is saved as a binary in a BLOB, see <a href="https://camel.apache.org/components/latest/sql-component.html#_database" rel="nofollow noreferrer">DATABASE</a>:</p>
  <blockquote>
  <p><strong>DATABASE</strong></p>
  <p>[...]</p>
  <p>The table structure definition of both table are identical: in both case a String value is used as key (id) whereas a Blob contains the exchange serialized in byte array.</p>
  </blockquote>
  <p><strong>Code</strong></p>
  <p>My model class is generated from JSON schema and implements <code>Serializable</code> to save the exchange in database:</p>
  <pre class="lang-java prettyprint-override"><code>public class MyMessage implements Serializable {
  
      @JsonProperty(&quot;value&quot;)
      private Integer value;
  }
  </code></pre>
  <p>My route unmarshals a JSON message into my model class and aggregate it:</p>
  <pre class="lang-java prettyprint-override"><code>from(direct(&quot;input&quot;))
      .unmarshal()
      .json(JsonLibrary.Jackson, MyMessage.class)
      .aggregate(header(&quot;CORRELATION_KEY&quot;), myAggregationStrategy)
      .aggregationRepository(myAggregationRepository)
      .completionSize(2)
      .marshal()
      .json()
      .to(&quot;output&quot;);
  </code></pre>
  <p>My aggregation repository:</p>
  <pre class="lang-java prettyprint-override"><code>@Bean
  public AggregationRepository myAggregationRepository(
      final PlatformTransactionManager platformTransactionManager, final DataSource dataSource) {
  
    final JdbcAggregationRepository repository = new JdbcAggregationRepository();
    repository.setRepositoryName(&quot;my_aggregation&quot;);
    repository.setTransactionManager(platformTransactionManager);
    repository.setDataSource(dataSource);
  
    return repository;
  }
  </code></pre>
  <p>I create the database tables with Flyway:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE my_aggregation (
   id varchar(255) NOT NULL,
   exchange blob NOT NULL,
   version BIGINT NOT NULL,
   constraint my_aggregation_pk PRIMARY KEY (id)
  );
  CREATE TABLE my_aggregation_completed (
   id varchar(255) NOT NULL,
   exchange blob NOT NULL,
   version BIGINT NOT NULL,
   constraint my_aggregation_completed_pk PRIMARY KEY (id)
  );
  </code></pre>
  <p><strong>Research</strong></p>
  <p>Apache Camel supports to save message body as text, see <a href="https://camel.apache.org/components/latest/sql-component.html#_storing_body_and_headers_as_text" rel="nofollow noreferrer">STORING BODY AND HEADERS AS TEXT</a>:</p>
  <blockquote>
  <p>You can configure the <code>JdbcAggregationRepository</code> to store message body and select(ed) headers as String in separate columns.</p>
  </blockquote>
  <p>But this additional column is not read by the aggregator.</p>
  <p><strong>Question</strong></p>
  <p>How can I migrate persisted exchanges in my database?</p>