Hi,
I am using Liquibase for database migration and I am also using contexts. But it doesn't seem to work correctly. I have a main config file (application.properties) that doesn't specify anything about liquibase contexts. I also have a liquibase file:
<changeSet id="test data" author="tribersoft" context="test-data">
<loadData tableName="unit" file="/db/test-data/unit.csv"></loadData>
</changeSet>
When I run an integration test that is annotated with following annotations (it also runs if i start the server for real):
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = TriberSensorApplication.class)
@WebAppConfiguration
@IntegrationTest("server.port:0")
I can see in the log file that the changeset ran. I expect it not to run as i am not configuring the 'test-data' context. If I add following line to the application.properties:
liquibase.contexts=none
It indeed doesn't run.
After reading the documentation I don't expect the changelogs from not-mentioned context to run, even if I don't specify a context. Now i need to configure a non-existing context to make sure the changelog doesn't run.
Did i misinterpret the documentation or is this a bug?
Spring Boot doesn't do too much with contexts other than pass them though to Liquibase.
Looking at the Liquibase documentation it appears that what you're describing is expected behavior:
If you do not specify a context when you run the migrator, ALL contexts will be run.
Most helpful comment
Spring Boot doesn't do too much with contexts other than pass them though to Liquibase.
Looking at the Liquibase documentation it appears that what you're describing is expected behavior: