Package ac.simons.neo4j.migrations.core
Class MigrationsConfig.Builder
java.lang.Object
ac.simons.neo4j.migrations.core.MigrationsConfig.Builder
- Enclosing class:
MigrationsConfig
A builder to create new instances of
configurations
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
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.withConstraintRenderingOptions
(Collection<? extends RenderConfig.AdditionalRenderingOptions> newRenderingOptions) Configures the rendering options for constraints defined by a catalog.withDatabase
(String newDatabase) Configures the database to apply Cypher-based migrations too.withDelayBetweenMigrations
(Duration newDelayBetweenMigrations) Some migrations, for example creating large indexes followed by large updates can cause an exception boiling down to {code Could not compile query due to insanely frequent schema changes}.withImpersonatedUser
(String newImpersonatedUser) Configures the impersonated user to use.withInstalledBy
(String newInstalledBy) Configures the user / principal name of the that is recorded in the MIGRATED_TO relationship asby
.withLocationsToScan
(String... locations) Configures the list of locations to scan.withMigrationClassesDiscoverer
(Discoverer<JavaBasedMigration> newMigrationClassesDiscoverer) withPackagesToScan
(String... packages) Configures the list of packages to scan.withResourceScanner
(ClasspathResourceScanner newResourceScanner) withSchemaDatabase
(String newSchemaDatabase) Configures the schema database to use.withTransactionMode
(MigrationsConfig.TransactionMode newTransactionMode) Configures the transaction mode.withValidateOnMigrate
(boolean newValidateOnMigrate) Validating helps you verify that the migrations applied to the database match the ones available locally and is on by default.withVersionSortOrder
(MigrationsConfig.VersionSortOrder newVersionSortOrder) Configures how versions are sorted.
-
Method Details
-
withPackagesToScan
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
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 atMigrationsConfig.TransactionMode
regarding advantages and disadvantages of each mode.- Parameters:
newTransactionMode
- The new transaction mode.- Returns:
- The builder for further customization
-
withDatabase
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
Configures the user / principal name of the that is recorded in the MIGRATED_TO relationship asby
. 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
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 withMigrationsConfig.isValidateOnMigrate()
to false.- Parameters:
newValidateOnMigrate
- The new value forvalidateOnMigrate
.- Returns:
- The builder for further customization
- Since:
- 0.2.1
-
withAutocrlf
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 forautocrlf
.- Returns:
- The builder for further customization
- Since:
- 0.3.1
-
withImpersonatedUser
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
Configures the schema database to use. This is different fromwithDatabase(String)
. The latter configures the database that should be migrated, the schema database configures the database that holds the migration chainTo 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
- 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
-
withDelayBetweenMigrations
Some migrations, for example creating large indexes followed by large updates can cause an exception boiling down to {code Could not compile query due to insanely frequent schema changes}. To prevent this, you can configure a static delay between migrations.- Parameters:
newDelayBetweenMigrations
- The delay to use. Use null to disable delay (which is the default)- Returns:
- The builder for further customization
- Since:
- 2.3.2
-
withConstraintRenderingOptions
public MigrationsConfig.Builder withConstraintRenderingOptions(Collection<? extends RenderConfig.AdditionalRenderingOptions> newRenderingOptions) Configures the rendering options for constraints defined by a catalog. Can be null but must not contain any null items.- Parameters:
newRenderingOptions
- The rendering options to use, a null argument resets the options.- Returns:
- The builder for further customization
- Throws:
NullPointerException
- ifnewRenderingOptions
contains null values- Since:
- 2.8.2
-
withVersionSortOrder
public MigrationsConfig.Builder withVersionSortOrder(MigrationsConfig.VersionSortOrder newVersionSortOrder) Configures how versions are sorted.- Parameters:
newVersionSortOrder
- the new order- Returns:
- The builder for further customization
- Since:
- 2.9.0
- See Also:
-
build
- Returns:
- The immutable configuration
-