Package io.ebean.config
Class DbMigrationConfig
- java.lang.Object
-
- io.ebean.config.DbMigrationConfig
-
public class DbMigrationConfig extends Object
Configuration for the DB migration processing.
-
-
Constructor Summary
Constructors Constructor Description DbMigrationConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.ebean.migration.MigrationRunner
createRunner(ClassLoader classLoader, Properties properties)
Create the MigrationRunner to run migrations if necessary.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
getDbSchema()
Return the DB schema to use (for migration, testing etc).String
getDbUsername()
Return the DB username to use for running DB migrations.String
getDdlHeader()
Returns a DDL header prepend for each DDL.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
getMigrationPath(boolean dbinitMigration)
Return the path for normal migrations or dbinit 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
getPatchInsertOn()
Return migration versions that should be added to history without running.String
getPatchResetChecksumOn()
Return migration versions that should have their checksum reset and not run.io.ebean.annotation.Platform
getPlatform()
Return the DB platform to generate migration DDL for.io.ebean.migration.MigrationConfig
getRunnerConfig()
Return the underlying migration runner configuration allowing for more advanced settings.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).boolean
isDefaultDbSchema()
Return true if this is considered the default DB schema (Postgres schema matching DB username).boolean
isRunMigration()
Return true if the DB migration should be run on startup.boolean
isStrictMode()
Return true if strict mode is used which includes a check that non-null columns have a default value.void
loadSettings(PropertiesWrapper properties, String serverName)
Load the settings from the PropertiesWrapper.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
setDbSchema(String dbSchema)
Set the Db schema to use.void
setDbUsername(String dbUsername)
Set the DB username to use for running DB migrations.void
setDdlHeader(String ddlHeader)
Set the header prepended to the DDL.void
setDefaultDbSchema(String dbSchema)
Set the Db schema if it hasn't already been defined.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
setPatchInsertOn(String patchInsertOn)
Set migration versions that should be added to history without running.void
setPatchResetChecksumOn(String patchResetChecksumOn)
Set migration versions that should have their checksum reset and not run.void
setPlatform(io.ebean.annotation.Platform 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
setStrictMode(boolean strictMode)
Set to false to turn off strict mode allowing non-null columns to not have a default value.
-
-
-
Constructor Detail
-
DbMigrationConfig
public DbMigrationConfig()
-
-
Method Detail
-
getPlatform
public io.ebean.annotation.Platform getPlatform()
Return the DB platform to generate migration DDL for.We typically need to explicitly specify this as migration can often be generated when running against H2.
-
setPlatform
public void setPlatform(io.ebean.annotation.Platform platform)
Set the DB platform to generate migration DDL for.
-
getMigrationPath
public String getMigrationPath(boolean dbinitMigration)
Return the path for normal migrations or dbinit migrations.- Parameters:
dbinitMigration
- When true return the path for dbinit migrations.
-
getMigrationPath
public String getMigrationPath()
Return the resource path for db migrations.
-
setMigrationPath
public void setMigrationPath(String migrationPath)
Set the resource path for db migrations.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 Database applications in the single classpath.
-
getModelPath
public String getModelPath()
Return the relative path for the model files (defaults to model).
-
setModelPath
public void setModelPath(String modelPath)
Set the relative path for the model files.
-
getModelSuffix
public String getModelSuffix()
Return the model suffix (defaults to model.xml)
-
setModelSuffix
public void setModelSuffix(String modelSuffix)
Set the model suffix.
-
getApplySuffix
public String getApplySuffix()
Return the apply script suffix (defaults to sql).
-
setApplySuffix
public void setApplySuffix(String applySuffix)
Set the apply script suffix (defaults to sql).
-
getApplyPrefix
public String getApplyPrefix()
Return the apply prefix.
-
setApplyPrefix
public void setApplyPrefix(String applyPrefix)
Set the apply prefix. This might be set to "V" for use with FlywayDB.
-
getMetaTable
public String getMetaTable()
Return the table name that holds the migration run details (used by DB Migration runner only).
-
setMetaTable
public void setMetaTable(String metaTable)
Set the table name that holds the migration run details (used by DB Migration runner only).
-
getRunPlaceholders
public String getRunPlaceholders()
Return a comma and equals delimited placeholders that are substituted in SQL scripts when running migration (used by DB Migration runner only).
-
setRunPlaceholders
public 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).
-
getRunPlaceholderMap
public 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).
-
setRunPlaceholderMap
public void setRunPlaceholderMap(Map<String,String> runPlaceholderMap)
Set a map of placeholder values that are substituted when running migration (used by DB Migration runner only).
-
isRunMigration
public boolean isRunMigration()
Return true if the DB migration should be run on startup.
-
setRunMigration
public void setRunMigration(boolean runMigration)
Set to true to run the DB migration on startup.
-
getDbUsername
public String getDbUsername()
Return the DB username to use for running DB migrations.
-
setDbUsername
public void setDbUsername(String dbUsername)
Set the DB username to use for running DB migrations.
-
getDbPassword
public String getDbPassword()
Return the DB password to use for running DB migrations.
-
setDbPassword
public void setDbPassword(String dbPassword)
Set the DB password to use for running DB migrations.
-
getDbSchema
public String getDbSchema()
Return the DB schema to use (for migration, testing etc).
-
setDbSchema
public void setDbSchema(String dbSchema)
Set the Db schema to use.
-
setDefaultDbSchema
public void setDefaultDbSchema(String dbSchema)
Set the Db schema if it hasn't already been defined.
-
isDefaultDbSchema
public boolean isDefaultDbSchema()
Return true if this is considered the default DB schema (Postgres schema matching DB username).
-
getPatchInsertOn
public String getPatchInsertOn()
Return migration versions that should be added to history without running.
-
setPatchInsertOn
public void setPatchInsertOn(String patchInsertOn)
Set migration versions that should be added to history without running.Value can be a string containing comma delimited list of version numbers.
-
getPatchResetChecksumOn
public String getPatchResetChecksumOn()
Return migration versions that should have their checksum reset and not run.
-
getDdlHeader
public String getDdlHeader()
Returns a DDL header prepend for each DDL. E.g. for copyright headers You can use placeholders like ${version} or ${timestamp} in properties file.
-
setDdlHeader
public void setDdlHeader(String ddlHeader)
Set the header prepended to the DDL.
-
setPatchResetChecksumOn
public void setPatchResetChecksumOn(String patchResetChecksumOn)
Set migration versions that should have their checksum reset and not run.Value can be a string containing comma delimited list of version numbers.
-
isStrictMode
public boolean isStrictMode()
Return true if strict mode is used which includes a check that non-null columns have a default value.
-
setStrictMode
public void setStrictMode(boolean strictMode)
Set to false to turn off strict mode allowing non-null columns to not have a default value.
-
getRunnerConfig
public io.ebean.migration.MigrationConfig getRunnerConfig()
Return the underlying migration runner configuration allowing for more advanced settings.
-
loadSettings
public void loadSettings(PropertiesWrapper properties, String serverName)
Load the settings from the PropertiesWrapper.
-
createRunner
public io.ebean.migration.MigrationRunner createRunner(ClassLoader classLoader, Properties properties)
Create the MigrationRunner to run migrations if necessary.
-
-