use of io.quarkus.agroal.spi.JdbcDataSourceSchemaReadyBuildItem in project quarkus by quarkusio.
the class FlywayProcessor method createBeansAndStartActions.
@BuildStep
@Consume(LoggingSetupBuildItem.class)
@Record(ExecutionTime.RUNTIME_INIT)
ServiceStartBuildItem createBeansAndStartActions(FlywayRecorder recorder, List<JdbcDataSourceBuildItem> jdbcDataSourceBuildItems, List<JdbcInitialSQLGeneratorBuildItem> sqlGeneratorBuildItems, BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer, BuildProducer<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem, MigrationStateBuildItem migrationsBuildItem) {
// make a FlywayContainerProducer bean
additionalBeans.produce(AdditionalBeanBuildItem.builder().addBeanClasses(FlywayContainerProducer.class).setUnremovable().setDefaultScope(DotNames.SINGLETON).build());
// add the @FlywayDataSource class otherwise it won't registered as a qualifier
additionalBeans.produce(AdditionalBeanBuildItem.builder().addBeanClass(FlywayDataSource.class).build());
recorder.resetFlywayContainers();
Collection<String> dataSourceNames = getDataSourceNames(jdbcDataSourceBuildItems);
for (String dataSourceName : dataSourceNames) {
boolean hasMigrations = migrationsBuildItem.hasMigrations.contains(dataSourceName);
boolean createPossible = false;
if (!hasMigrations) {
createPossible = sqlGeneratorBuildItems.stream().anyMatch(s -> s.getDatabaseName().equals(dataSourceName));
}
SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem.configure(Flyway.class).scope(// this is what the existing code does, but it doesn't seem reasonable
Dependent.class).setRuntimeInit().unremovable().supplier(recorder.flywaySupplier(dataSourceName, hasMigrations, createPossible));
if (DataSourceUtil.isDefault(dataSourceName)) {
configurator.addQualifier(Default.class);
} else {
String beanName = FLYWAY_BEAN_NAME_PREFIX + dataSourceName;
configurator.name(beanName);
configurator.addQualifier().annotation(DotNames.NAMED).addValue("value", beanName).done();
configurator.addQualifier().annotation(FlywayDataSource.class).addValue("value", dataSourceName).done();
}
syntheticBeanBuildItemBuildProducer.produce(configurator.done());
}
// will actually run the actions at runtime
recorder.doStartActions();
// once we are done running the migrations, we produce a build item indicating that the
// schema is "ready"
schemaReadyBuildItem.produce(new JdbcDataSourceSchemaReadyBuildItem(migrationsBuildItem.hasMigrations));
return new ServiceStartBuildItem("flyway");
}
use of io.quarkus.agroal.spi.JdbcDataSourceSchemaReadyBuildItem in project quarkus by quarkusio.
the class LiquibaseProcessor method startLiquibase.
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
@Consume(SyntheticBeansRuntimeInitBuildItem.class)
ServiceStartBuildItem startLiquibase(LiquibaseRecorder recorder, List<JdbcDataSourceBuildItem> jdbcDataSourceBuildItems, BuildProducer<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem) {
// will actually run the actions at runtime
recorder.doStartActions();
// once we are done running the migrations, we produce a build item indicating that the
// schema is "ready"
schemaReadyBuildItem.produce(new JdbcDataSourceSchemaReadyBuildItem(getDataSourceNames(jdbcDataSourceBuildItems)));
return new ServiceStartBuildItem("liquibase");
}
Aggregations