Package ac.simons.neo4j.migrations.core
Class Migrations
java.lang.Object
ac.simons.neo4j.migrations.core.Migrations
Main entry to Neo4j Migrations
- Since:
- 0.0.1
- Author:
- Michael J. Simons
-
Constructor Summary
ConstructorDescriptionMigrations
(MigrationsConfig config, org.neo4j.driver.Driver driver) Creates amigrations instance
ready to used with the given configuration over the connection defined by thedriver
. -
Method Summary
Modifier and TypeMethodDescriptionapply()
Applies all discovered Neo4j migrations.apply
(boolean log) Applies all discovered Neo4j migrations.apply
(Refactoring... refactorings) Applies one or more refactorings to the target (not the schema) database.int
Applies one or more migrations to the target (not the schema) database without recording any metadata and also without acquiring the lock.clean
(boolean all) Cleans theselected schema database
.Retrieves the database catalogRetrieves the local catalog, containing constraints and indexes.static String
info()
Returns information about the context, the database, all applied and all pending applications.info
(MigrationChain.ChainBuilderMode infoCmd) Returns information about the context, the database, all applied and all pending applications.validate()
Validates the database against the resolved migrations.
-
Constructor Details
-
Migrations
Creates amigrations instance
ready to used with the given configuration over the connection defined by thedriver
.- Parameters:
config
- The configuration to usedriver
- The connection
-
-
Method Details
-
getConnectionDetails
- Returns:
- Information about the connection when migrations are applied, validated and so on.
- Since:
- 1.4.0
- See Also:
-
info
Returns information about the context, the database, all applied and all pending applications.- Returns:
- The chain of migrations.
- Throws:
org.neo4j.driver.exceptions.ServiceUnavailableException
- in case the driver is not connectedMigrationsException
- for everything caused by failing migrations- Since:
- 0.0.4
- See Also:
-
info
Returns information about the context, the database, all applied and all pending applications.- Parameters:
infoCmd
- Specify how the chain should be computed- Returns:
- The chain of migrations.
- Throws:
org.neo4j.driver.exceptions.ServiceUnavailableException
- in case the driver is not connectedMigrationsException
- for everything caused by failing migrations- Since:
- 1.4.0
-
apply
Applies all discovered Neo4j migrations. Migrations can either be classes implementingJavaBasedMigration
or Cypher script migrations that are on the classpath or filesystem.- Returns:
- The last applied migration (if any)
- Throws:
org.neo4j.driver.exceptions.ServiceUnavailableException
- in case the driver is not connectedMigrationsException
- for everything caused by failing migrations- Since:
- 0.0.1
- See Also:
-
apply
Applies all discovered Neo4j migrations. Migrations can either be classes implementingJavaBasedMigration
or Cypher script migrations that are on the classpath or filesystem.The startup will be logged to
ac.simons.neo4j.migrations.core.Migrations.Startup
and can be individiually disabled through that logger.- Parameters:
log
- set to true to log connection details prior to applying the migrations- Returns:
- The last applied migration (if any)
- Throws:
org.neo4j.driver.exceptions.ServiceUnavailableException
- in case the driver is not connectedMigrationsException
- for everything caused by failing migrations- Since:
- 1.12.0
-
apply
Applies one or more refactorings to the target (not the schema) database.- Parameters:
refactorings
- the refactorings to apply- Returns:
- summarized counters
- Since:
- 1.13.0
-
apply
Applies one or more migrations to the target (not the schema) database without recording any metadata and also without acquiring the lock.- Parameters:
resources
- One or more resources pointing to parsable migration data- Returns:
- the number of migrations applied
- Since:
- 1.13.0
-
clean
Cleans theselected schema database
. If there is no schema database selected, looks in thetarget database.
If this isn't configured as well, the users home database will be searched for- Migration chains (those are the nodes containing information about the applied migrations
- Any log from this tool
- Any constraints created by this tool
- Parameters:
all
- Set to true to remove all constructs created by Neo4j-Migrations, set to false to remove all the migration chain for the selected or automatically determined target database.- Returns:
- The result of cleaning the database.
- Throws:
org.neo4j.driver.exceptions.ServiceUnavailableException
- in case the driver is not connectedMigrationsException
- for everything caused due to schema objects not deletable- Since:
- 1.1.0
-
validate
Validates the database against the resolved migrations. A database is considered to be in a valid state when all resolved migrations have been applied (there are no more pending migrations). If a database is not yet fully migrated, it won't identify asValidationResult.Outcome.VALID
but it will indicate viaValidationResult.needsRepair()
that it doesn't need repair. Applying the pending migrations viaapply()
will bring the database into a valid state. Most other outcomes not valid need to be manually fix. One radical fix is callingclean(boolean)
with the same configuration.- Returns:
- a validation result, with an outcome, a possible list of warnings and indicators if the database is in a valid state
- Since:
- 1.2.0
-
getLocalCatalog
Retrieves the local catalog, containing constraints and indexes.- Returns:
- the local catalog
- Since:
- 1.7.0
-
getDatabaseCatalog
Retrieves the database catalog- Returns:
- the database catalog
- Since:
- 1.7.0
-
getUserAgent
- Returns:
- the user agent for Neo4j-Migrations (given in the form name/version).
- Since:
- 1.2.1
-