public class DbMigrationConfig extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
applySuffix |
protected boolean |
generate
Set to true if the DB migration should be generated on server start.
|
protected String |
generatePendingDrop
The version of a pending drop that should be generated as the next migration.
|
protected boolean |
includeGeneratedFileComment |
protected static org.slf4j.Logger |
logger |
protected String |
migrationPath
Resource path for the migration xml and sql.
|
protected String |
modelPath
Subdirectory the model xml files go into.
|
protected String |
modelSuffix |
protected String |
name
Description text that can be appended to the version to become the ddl script file name.
|
protected DbPlatformName |
platform
The database platform to generate migration DDL for.
|
protected String |
version
The migration version name (typically FlywayDb compatible).
|
| Constructor and Description |
|---|
DbMigrationConfig() |
| Modifier and Type | Method and Description |
|---|---|
void |
generateOnStart(EbeanServer server)
Called by EbeanServer on start.
|
String |
getApplySuffix()
Return the apply script suffix (defaults to sql).
|
String |
getGeneratePendingDrop()
Return the migration version (or "next") to generate pending drops for.
|
String |
getMigrationPath()
Return the resource path for db migrations.
|
String |
getModelPath()
Return the relative path for the model files (defaults to model).
|
String |
getModelSuffix()
Return the model suffix (defaults to model.xml)
|
String |
getName()
Return the migration name which is short description text that can be appended to
the migration version to become the ddl script file name.
|
DbPlatformName |
getPlatform()
Return the DB platform to generate migration DDL for.
|
String |
getVersion()
Return the migration version (typically FlywayDb compatible).
|
protected boolean |
isEmpty(String val)
Return true if the string is null or empty.
|
boolean |
isGenerateOnStart()
Return true if the migration should be generated.
|
boolean |
isIncludeGeneratedFileComment()
Return true if the generated file comment should be included.
|
void |
loadSettings(PropertiesWrapper properties)
Load the settings from the PropertiesWrapper.
|
protected String |
readEnvironment(String key)
Return the system or environment property.
|
void |
setApplySuffix(String applySuffix)
Set the apply script suffix (defaults to sql).
|
void |
setGeneratePendingDrop(String generatePendingDrop)
Set the migration version (or "next") to generate pending drops for.
|
void |
setIncludeGeneratedFileComment(boolean includeGeneratedFileComment)
Set to true if the generated file comment should be included.
|
void |
setMigrationPath(String migrationPath)
Set the resource path for db migrations.
|
void |
setModelPath(String modelPath)
Set the relative path for the model files.
|
void |
setModelSuffix(String modelSuffix)
Set the model suffix.
|
void |
setName(String name)
Set the migration name.
|
void |
setPlatform(DbPlatformName platform)
Set the DB platform to generate migration DDL for.
|
void |
setVersion(String version)
Set the migration version.
|
void |
singleDirectory()
Set the model, rollback and drop paths to be empty such that all the migration files are generated
into a single directory.
|
protected static final org.slf4j.Logger logger
protected DbPlatformName platform
protected boolean generate
protected String version
Example: 1.1.1_2
The version is expected to be the combination of the current pom version plus a 'feature' id. The combined version must be unique and ordered to work with FlywayDb so each developer sets a unique version so that the migration script generated is unique (typically just prior to being submitted as a merge request).
protected String name
So if the name is "a foo table" then the ddl script file could be: "1.1.1_2__a-foo-table.sql"
When the DB migration relates to a git feature (merge request) then this description text is a short description of the feature.
protected String migrationPath
protected String applySuffix
protected String modelSuffix
protected boolean includeGeneratedFileComment
protected String generatePendingDrop
public DbMigrationConfig()
public DbPlatformName getPlatform()
public void setPlatform(DbPlatformName platform)
public String getMigrationPath()
public void setMigrationPath(String migrationPath)
The default of "dbmigration" is reasonable in most cases. You may look to set this to be something like "dbmigration/myapp" where myapp gives it a unique resource path in the case there are multiple EbeanServer applications in the single classpath.
public String getModelPath()
public void setModelPath(String modelPath)
public String getModelSuffix()
public void setModelSuffix(String modelSuffix)
public String getApplySuffix()
public void setApplySuffix(String applySuffix)
public boolean isIncludeGeneratedFileComment()
public void setIncludeGeneratedFileComment(boolean includeGeneratedFileComment)
public String getGeneratePendingDrop()
public void setGeneratePendingDrop(String generatePendingDrop)
public void setVersion(String version)
Note that version set via System property or environment variable ddl.migration.version takes precedence.
public void setName(String name)
Note that name set via System property or environment variable ddl.migration.name takes precedence.
public void singleDirectory()
public void loadSettings(PropertiesWrapper properties)
public boolean isGenerateOnStart()
It is expected that when an environment variable ddl.migration.enabled
is set to true then the DB migration will generate the migration DDL.
public void generateOnStart(EbeanServer server)
If enabled this generates the migration xml and DDL scripts.
public String getVersion()
Example: 1.1.1_2
The version is expected to be the combination of the current pom version plus a 'feature' id. The combined version must be unique and ordered to work with FlywayDb so each developer sets a unique version so that the migration script generated is unique (typically just prior to being submitted as a merge request).
public String getName()
So if the name is "a foo table" then the ddl script file could be: "1.1.1_2__a-foo-table.sql"
When the DB migration relates to a git feature (merge request) then this description text is a short description of the feature.
protected String readEnvironment(String key)
Copyright © 2016. All rights reserved.