It's difficult to share a single database instance across branches of your code. It causes the same sorts of problems, if you tried sharing the database across multiple developers.
Liquibase is designed to use the file based changesets as the master record for database change. The special table DATABASECHANGELOG is designed track which changesets have been applied to the database instance. Switching between branches causes confusion in lots of unpredictable ways, for example:
- Missing changesets
- Changesets whose content has changed (Leads to checksum errors).
- ...
The best advice is to refresh or resync the database, whenever you switch between branches:
liquibase dropAll
liquibase update
In your case the second operation is probabily unnecessary as the liquibase servlet would update the database on startup.
If you have concerns about losing data, then use contexts to control test data.
Update
If you're using Maven this "resync" operation can be called from Maven as follows:
mvn -Presync compile
This profile is configured within your POM as follows:
<profile>
<id>resync</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.plugin.version}</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<url>${liquibase.url}</url>
<driver>${liquibase.driver}</driver>
<username>${liquibase.username}</username>
<password>${liquibase.password}</password>
<changeLogFile>${liquibase.changeLogFile}</changeLogFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<goals>
<goal>dropAll</goal>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>