Spring-boot: Liquibase context

Created on 18 Nov 2015  路  1Comment  路  Source: spring-projects/spring-boot

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?

invalid

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:

If you do not specify a context when you run the migrator, ALL contexts will be run.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings