Package io.micronaut.liquibase
Class LiquibaseMigrator
java.lang.Object
io.micronaut.liquibase.AbstractLiquibaseMigration
io.micronaut.liquibase.LiquibaseMigrator
- All Implemented Interfaces:
io.micronaut.context.event.BeanCreatedEventListener<DataSource>
,EventListener
Public access to invoke Liquibase migrations when DataSource onCreate behaviour is not desired.
The Liquibase configuration should be: liquibase.enabled = true liquibase.datasources.*.enabled = false
This ensures that Liquibase won't run automatically the migrations. The following service can then be injected later
and either forceRun or safeRun a migration based on a given LiquibaseConfigurationProperties
.
- Since:
- 3.2.0
- Author:
- Kevin Jouper, Iván López
-
Constructor Summary
ConstructorDescriptionLiquibaseMigrator
(io.micronaut.context.ApplicationContext applicationContext, liquibase.resource.ResourceAccessor resourceAccessor, @Nullable io.micronaut.jdbc.DataSourceResolver dataSourceResolver) -
Method Summary
Modifier and TypeMethodDescriptiononCreated
(io.micronaut.context.event.BeanCreatedEvent<DataSource> event) void
run
(LiquibaseConfigurationProperties config, DataSource dataSource) Run the Liquibase migrations for a specific config and a DataSource.
-
Constructor Details
-
LiquibaseMigrator
public LiquibaseMigrator(io.micronaut.context.ApplicationContext applicationContext, liquibase.resource.ResourceAccessor resourceAccessor, @Nullable @Nullable io.micronaut.jdbc.DataSourceResolver dataSourceResolver) - Parameters:
applicationContext
- The application contextresourceAccessor
- An implementation ofResourceAccessor
dataSourceResolver
- The data source resolver
-
-
Method Details
-
onCreated
- Specified by:
onCreated
in interfaceio.micronaut.context.event.BeanCreatedEventListener<DataSource>
-
run
Run the Liquibase migrations for a specific config and a DataSource.- Parameters:
config
- TheLiquibaseConfigurationProperties
dataSource
- TheDataSource
-