@Provides
    @Singleton
    public LegacyDbConnProvider getConnectionProvider(final Provider<LegacyDbConfig> configProvider,
                                                      final DataSourceFactory dataSourceFactory) {
        LOGGER.debug(() -> "Getting connection provider for " + getModuleName());

        final DataSource dataSource = dataSourceFactory.create(configProvider.get(), getModuleName(), false);

        // Prevent migrations from being re-run for each test
        final boolean hasModuleBeenMigrated = !COMPLETED_MIGRATIONS.computeIfAbsent(
                dataSource,
                k -> Collections.newSetFromMap(new ConcurrentHashMap<>()))
                .add(getModuleName());

        final boolean haveBootstrapMigrationsBeenDone = DbMigrationState.haveBootstrapMigrationsBeenDone();

        LOGGER.debug(() ->
                LogUtil.message("Module {}, hasModuleBeenMigrated: {}, haveBootstrapMigrationsBeenDone: {}",
                        getModuleName(), hasModuleBeenMigrated, haveBootstrapMigrationsBeenDone));

        // haveBootstrapMigrationsBeenDone gets set as part of the bootstrapping in App, whereas
        // hasModuleBeenMigrated controls test runs where the app bootstrapping may not have been
        // done.
        if (haveBootstrapMigrationsBeenDone) {
            LOGGER.debug(() -> LogUtil.message(
                    "Stroom has already been migrated to this build version (module: {}).", getModuleName()));
        } else {
            if (!hasModuleBeenMigrated) {
                performMigration(dataSource);
            } else {
                LOGGER.debug(() -> LogUtil.message("Module {} has already been migrated.", getModuleName()));
            }
        }

        return createConnectionProvider(dataSource);
    }
Configures anything related to persistence, e.g. transaction management, the
entity manager factory, data sources.
<p>
This does not extend {@link stroom.db.util.AbstractDataSourceProviderModule} as the core migrations
are special and need to happen first before all the other migrations. {@link ForceLegacyMigration} is
used to achieve this by making all other datasource providers depend on {@link ForceLegacyMigration}.
stroom-legacy/stroom-legacy-db-migration/src/main/java/stroom/legacy/db/LegacyDbModule.java