Class MigrationsConfig.Builder

java.lang.Object
ac.simons.neo4j.migrations.core.MigrationsConfig.Builder
Enclosing class:
MigrationsConfig

public static class MigrationsConfig.Builder extends Object
A builder to create new instances of configurations.
  • Constructor Details

  • Method Details

    • withPackagesToScan

      public MigrationsConfig.Builder withPackagesToScan(String... packages)
      Configures the list of packages to scan. Default is an empty list.
      Parameters:
      packages - one or more packages to scan.
      Returns:
      The builder for further customization
    • withLocationsToScan

      public MigrationsConfig.Builder withLocationsToScan(String... locations)
      Configures the list of locations to scan. Defaults to a single entry of `classpath:neo4j/migrations`.
      Parameters:
      locations - one or more locations to scan. Can start either with `classpath:` or `file:`. Locations without prefix are treated as classpath resources.
      Returns:
      The builder for further customization
    • withTransactionMode

      public MigrationsConfig.Builder withTransactionMode(MigrationsConfig.TransactionMode newTransactionMode)
      Configures the transaction mode. Please have a look at MigrationsConfig.TransactionMode regarding advantages and disadvantages of each mode.
      Parameters:
      newTransactionMode - The new transaction mode.
      Returns:
      The builder for further customization
    • withDatabase

      public MigrationsConfig.Builder withDatabase(String newDatabase)
      Configures the database to apply Cypher-based migrations too. Leave null for the default database.
      Parameters:
      newDatabase - The database to use
      Returns:
      The builder for further customization
    • withInstalledBy

      public MigrationsConfig.Builder withInstalledBy(String newInstalledBy)
      Configures the user / principal name of the that is recorded in the MIGRATED_TO relationship as by. Defaults to the OS user.
      Parameters:
      newInstalledBy - An arbitrary string to represent the service having installed the migrations
      Returns:
      The builder for further customization
      Since:
      0.0.6
    • withValidateOnMigrate

      public MigrationsConfig.Builder withValidateOnMigrate(boolean newValidateOnMigrate)
      Validating helps you verify that the migrations applied to the database match the ones available locally and is on by default. It can be turned off by using a configuration with MigrationsConfig.isValidateOnMigrate() to false.
      Parameters:
      newValidateOnMigrate - The new value for validateOnMigrate.
      Returns:
      The builder for further customization
      Since:
      0.2.1
    • withAutocrlf

      public MigrationsConfig.Builder withAutocrlf(boolean newAutocrlf)
      If you're programming on Windows and working with people who are not (or vice-versa), you'll probably run into line-ending issues at some point. This is because Windows uses both a carriage-return character and a linefeed character for newlines in its files, whereas macOS and Linux systems use only the linefeed character. This is a subtle but incredibly annoying fact of cross-platform work; many editors on Windows silently replace existing LF-style line endings with CRLF, or insert both line-ending characters when the user hits the enter key. Neo4j migrations can handle this by auto-converting CRLF line endings into LF before computing checksums of a Cypher-based migration or applying it.
      Parameters:
      newAutocrlf - The new value for autocrlf.
      Returns:
      The builder for further customization
      Since:
      0.3.1
    • withImpersonatedUser

      public MigrationsConfig.Builder withImpersonatedUser(String newImpersonatedUser)
      Configures the impersonated user to use. This works only with Neo4j 4.4+ Enterprise and a Neo4j 4.4+ driver. The feature comes in handy for escalating privileges during the time of migrations and dropping them again for further use of a connection.
      Parameters:
      newImpersonatedUser - A user to impersonate
      Returns:
      The builder for further customization
      Since:
      1.0.0
    • withSchemaDatabase

      public MigrationsConfig.Builder withSchemaDatabase(String newSchemaDatabase)
      Configures the schema database to use. This is different from withDatabase(String). The latter configures the database that should be migrated, the schema database configures the database that holds the migration chain

      To use this, Neo4j 4+ enterprise edition is required.

      Parameters:
      newSchemaDatabase - The new schema database to use.
      Returns:
      The builder for further customization
      Since:
      1.1.0
    • withMigrationClassesDiscoverer

      public MigrationsConfig.Builder withMigrationClassesDiscoverer(Discoverer<JavaBasedMigration> newMigrationClassesDiscoverer)
      Parameters:
      newMigrationClassesDiscoverer - The discoverer for (Java) class based migrations. Set to null to use the default.
      Returns:
      The builder for further customization
      Since:
      1.3.0
    • withResourceScanner

      public MigrationsConfig.Builder withResourceScanner(ClasspathResourceScanner newResourceScanner)
      Parameters:
      newResourceScanner - The Cypher resource scanner to be used. Set to null to use the default.
      Returns:
      The builder for further customization
      Since:
      1.3.0
    • build

      public MigrationsConfig build()
      Returns:
      The immutable configuration