public class DbMigrationConfig extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
applyPrefix
Set this to "V" to be compatible with FlywayDB.
|
protected String |
applySuffix |
protected String |
dbPassword
DB password used to run the DB migration.
|
protected String |
dbUsername
DB user used to run the DB migration.
|
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 |
metaTable
For running migration the DB table that holds migration execution status.
|
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 boolean |
runMigration
Flag set to true means to run any outstanding migrations on startup.
|
protected Map<String,String> |
runPlaceholderMap
Map of key/value placeholders to replace in DDL scripts.
|
protected String |
runPlaceholders
Comma and equals delimited key/value placeholders to replace in DDL scripts.
|
protected String |
version
The migration version name (typically FlywayDb compatible).
|
Constructor and Description |
---|
DbMigrationConfig() |
Modifier and Type | Method and Description |
---|---|
org.avaje.dbmigration.MigrationRunner |
createRunner(ClassLoader classLoader)
Create the MigrationRunner to run migrations if necessary.
|
void |
generateOnStart(EbeanServer server)
Called by EbeanServer on start.
|
String |
getApplyPrefix()
Return the apply prefix.
|
String |
getApplySuffix()
Return the apply script suffix (defaults to sql).
|
String |
getDbPassword()
Return the DB password to use for running DB migrations.
|
String |
getDbUsername()
Return the DB username to use for running DB migrations.
|
String |
getGeneratePendingDrop()
Return the migration version (or "next") to generate pending drops for.
|
String |
getMetaTable()
Return the table name that holds the migration run details
(used by DB Migration runner only).
|
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.
|
Map<String,String> |
getRunPlaceholderMap()
Return a map of placeholder values that are substituted in SQL scripts when running migration
(used by DB Migration runner only).
|
String |
getRunPlaceholders()
Return a comma and equals delimited placeholders that are substituted in SQL scripts when running migration
(used by DB Migration runner only).
|
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.
|
boolean |
isRunMigration()
Return true if the DB migration should be run on startup.
|
void |
loadSettings(PropertiesWrapper properties,
String serverName)
Load the settings from the PropertiesWrapper.
|
protected String |
readEnvironment(String key)
Return the system or environment property.
|
void |
setApplyPrefix(String applyPrefix)
Set the apply prefix.
|
void |
setApplySuffix(String applySuffix)
Set the apply script suffix (defaults to sql).
|
void |
setDbPassword(String dbPassword)
Set the DB password to use for running DB migrations.
|
void |
setDbUsername(String dbUsername)
Set the DB username to use for running DB migrations.
|
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 |
setMetaTable(String metaTable)
Set the table name that holds the migration run details
(used by DB Migration runner only).
|
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 |
setRunMigration(boolean runMigration)
Set to true to run the DB migration on startup.
|
void |
setRunPlaceholderMap(Map<String,String> runPlaceholderMap)
Set a map of placeholder values that are substituted when running migration
(used by DB Migration runner only).
|
void |
setRunPlaceholders(String runPlaceholders)
Set a comma and equals delimited placeholders that are substituted in SQL scripts when running migration
(used by DB Migration runner only).
|
void |
setVersion(String version)
Set the migration version.
|
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 applyPrefix
protected String modelSuffix
protected boolean includeGeneratedFileComment
protected String generatePendingDrop
protected String metaTable
protected boolean runMigration
protected String runPlaceholders
protected Map<String,String> runPlaceholderMap
protected String dbUsername
protected String dbPassword
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 String getApplyPrefix()
public void setApplyPrefix(String applyPrefix)
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 String getMetaTable()
public void setMetaTable(String metaTable)
public String getRunPlaceholders()
public void setRunPlaceholders(String runPlaceholders)
public Map<String,String> getRunPlaceholderMap()
public void setRunPlaceholderMap(Map<String,String> runPlaceholderMap)
public boolean isRunMigration()
public void setRunMigration(boolean runMigration)
public String getDbUsername()
public void setDbUsername(String dbUsername)
public String getDbPassword()
public void setDbPassword(String dbPassword)
public void loadSettings(PropertiesWrapper properties, String serverName)
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)
public org.avaje.dbmigration.MigrationRunner createRunner(ClassLoader classLoader)
Copyright © 2016. All rights reserved.