title: Databases and "branch"
body: <p>We are currently developping an application which use a database.</p>
  
  <p>Every time we update the database structure, we have to provide a script to update the database from the previous version to the current one.</p>
  
  <p>So the database has currently a number that gave us it's current version and then our software make an update when we want to use an "old" database.</p>
  
  <p>The issue we are encountering is when we have branches:</p>
  
  <p>When we create a new big feature, that will not be available for users(and not included in releases), we create a branch.</p>
  
  <p>The main branch(trunk) will be merged regularly to ensure that the create brunch has the latest bug corrections.</p>
  
  <p>Here is some illustration:
  <img src="https://i.stack.imgur.com/TM3mu.png" alt="enter image description here"></p>
  
  <p>The issue is with our update scripts. They update from the previous version to the current one, then update the version number of the database.</p>
  
  <p>Imagine that we have the DB version 17 when creating the branch. </p>
  
  <p>We then do the branch, and make changes on the Trunk DB. The DB has now the version 18.</p>
  
  <p>Then we make a db change on the branch. Since we know there has already been a new version "18", we create the version 19 and the updater 18->19.</p>
  
  <p>Then the trunk is merged on the branch.</p>
  
  <p>At this very moment we may have some updaters that will never runs.</p>
  
  <p>If someone updated his database before the merge, his database will be flagged has having the version 19, the the update 17->18 will never be done.</p>
  
  <p>We want to change this behavior but we can't find how:</p>
  
  <p>Our constraints are:</p>
  
  <ul>
  <li>We are unable to make all changes on the same branch</li>
  <li>Sometimes we have more than just 2 branchs, and we can only merge from the trunk to the feature branch until the feature is finished</li>
  </ul>
  
  <p>What can we do to ensure a continuity between our database branch?</p>