Class BaseDatabase<C extends Connection<?>>
java.lang.Object
migratedb.v1.core.internal.database.base.BaseDatabase<C>
- All Implemented Interfaces:
Closeable,AutoCloseable,Database<C>
- Direct Known Subclasses:
BigQueryDatabase,CockroachDBDatabase,DB2Database,DerbyDatabase,FirebirdDatabase,H2Database,HSQLDBDatabase,IgniteThinDatabase,InformixDatabase,MySQLDatabase,OracleDatabase,PostgreSQLDatabase,RedshiftDatabase,SAPHANADatabase,SnowflakeDatabase,SpannerDatabase,SQLiteDatabase,SQLServerDatabase,SybaseASEDatabase
Abstraction for database-specific functionality.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Configurationprotected final DatabaseTypeprotected final JdbcConnectionFactoryprotected final DatabaseMetaDataprotected JdbcTemplateprotected final ConnectionThe main JDBC connection, without any wrapping. -
Constructor Summary
ConstructorsConstructorDescriptionBaseDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanPostSchemas(Schema<?, ?>[] schemas) Cleans all the objects in this database that need to be cleaned after each schema.voidCleans all the objects in this database that need to be cleaned before each schema.voidclose()protected StringcomputeVersionDisplayName(Version version) Compute the user-friendly display name for this database version.protected Versionprotected voiddoCleanPostSchemas(Schema<?, ?>[] schemas) Cleans all the objects in this database that need to be cleaned after each schema.protected voidCleans all the objects in this database that need to be cleaned before each schema.protected Stringprotected abstract CdoGetConnection(Connection connection) Retrieves a MigrateDB Connection for this JDBC connection.protected Stringprotected StringQuotes this identifier for use in SQL queries.protected final voidensureDatabaseIsRecentEnough(String oldestSupportedVersion) Schema<?,?>[] final StringgetBaselineStatement(Table<?, ?> table) final Stringprotected Stringfinal SqlScriptgetCreateScript(SqlScriptFactory sqlScriptFactory, Table<?, ?> table, boolean baseline) Retrieves the script used to create the schema history table.final Stringprotected StringgetInsertStatement(Table<?, ?> table) final Stringfinal Cfinal Cprotected StringgetSelectStatement(Table<?, ?> table) final Versionfinal StringQuotes these identifiers for use in SQL queries.protected final voidrecommendMigrateDbUpgradeIfNecessary(String newestSupportedVersion) protected final voidrecommendMigrateDbUpgradeIfNecessaryForMajorVersion(String newestSupportedVersion) booleanbooleanbooleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface migratedb.v1.core.api.internal.database.base.Database
catalogIsSchema, ensureSupported, getBooleanFalse, getBooleanTrue, getRawCreateScript, supportsChangingCurrentSchema, supportsDdlTransactions
-
Field Details
-
databaseType
-
configuration
-
jdbcConnectionFactory
-
jdbcMetaData
-
jdbcTemplate
-
rawMainJdbcConnection
The main JDBC connection, without any wrapping.
-
-
Constructor Details
-
BaseDatabase
-
-
Method Details
-
doGetConnection
Retrieves a MigrateDB Connection for this JDBC connection. -
getVersion
- Specified by:
getVersionin interfaceDatabase<C extends Connection<?>>- Returns:
- The 'major.minor' version of this database.
-
ensureDatabaseIsRecentEnough
-
recommendMigrateDbUpgradeIfNecessary
-
recommendMigrateDbUpgradeIfNecessaryForMajorVersion
protected final void recommendMigrateDbUpgradeIfNecessaryForMajorVersion(String newestSupportedVersion) -
computeVersionDisplayName
Compute the user-friendly display name for this database version. -
getDefaultDelimiter
- Specified by:
getDefaultDelimiterin interfaceDatabase<C extends Connection<?>>
-
getCatalog
- Specified by:
getCatalogin interfaceDatabase<C extends Connection<?>>- Returns:
- The name of the database, by default as determined by JDBC.
-
doGetCatalog
- Throws:
SQLException
-
getCurrentUser
- Specified by:
getCurrentUserin interfaceDatabase<C extends Connection<?>>
-
doGetCurrentUser
- Throws:
SQLException
-
quote
Description copied from interface:DatabaseQuotes these identifiers for use in SQL queries. Multiple identifiers will be quoted and separated by a dot.- Specified by:
quotein interfaceDatabase<C extends Connection<?>>
-
doQuote
Quotes this identifier for use in SQL queries. -
getOpenQuote
-
getCloseQuote
-
getEscapedQuote
-
unQuote
- Specified by:
unQuotein interfaceDatabase<C extends Connection<?>>
-
useSingleConnection
public boolean useSingleConnection()- Specified by:
useSingleConnectionin interfaceDatabase<C extends Connection<?>>- Returns:
- Whether to use a single connection for both schema history table management and applying migrations.
-
getJdbcMetaData
- Specified by:
getJdbcMetaDatain interfaceDatabase<C extends Connection<?>>
-
getMainConnection
- Specified by:
getMainConnectionin interfaceDatabase<C extends Connection<?>>- Returns:
- The main connection used to manipulate the schema history.
-
getMigrationConnection
- Specified by:
getMigrationConnectionin interfaceDatabase<C extends Connection<?>>- Returns:
- The migration connection used to apply migrations.
-
determineVersion
- Returns:
- The major and minor version of the database.
-
getCreateScript
public final SqlScript getCreateScript(SqlScriptFactory sqlScriptFactory, Table<?, ?> table, boolean baseline) Description copied from interface:DatabaseRetrieves the script used to create the schema history table.- Specified by:
getCreateScriptin interfaceDatabase<C extends Connection<?>>- Parameters:
sqlScriptFactory- The factory used to create the SQL script.table- The table to create.baseline- Whether to include the creation of a baseline marker.
-
getInsertStatement
- Specified by:
getInsertStatementin interfaceDatabase<C extends Connection<?>>
-
getBaselineStatement
- Specified by:
getBaselineStatementin interfaceDatabase<C extends Connection<?>>
-
getSelectStatement
- Specified by:
getSelectStatementin interfaceDatabase<C extends Connection<?>>
-
getInstalledBy
- Specified by:
getInstalledByin interfaceDatabase<C extends Connection<?>>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceDatabase<C extends Connection<?>>
-
getDatabaseType
- Specified by:
getDatabaseTypein interfaceDatabase<C extends Connection<?>>
-
supportsEmptyMigrationDescription
public boolean supportsEmptyMigrationDescription()- Specified by:
supportsEmptyMigrationDescriptionin interfaceDatabase<C extends Connection<?>>
-
supportsMultiStatementTransactions
public boolean supportsMultiStatementTransactions()- Specified by:
supportsMultiStatementTransactionsin interfaceDatabase<C extends Connection<?>>
-
cleanPreSchemas
public void cleanPreSchemas()Description copied from interface:DatabaseCleans all the objects in this database that need to be cleaned before each schema.- Specified by:
cleanPreSchemasin interfaceDatabase<C extends Connection<?>>
-
doCleanPreSchemas
Cleans all the objects in this database that need to be cleaned before each schema.- Throws:
SQLException- when the clean failed.
-
cleanPostSchemas
Description copied from interface:DatabaseCleans all the objects in this database that need to be cleaned after each schema.- Specified by:
cleanPostSchemasin interfaceDatabase<C extends Connection<?>>- Parameters:
schemas- The list of schemas managed by MigrateDB.
-
doCleanPostSchemas
Cleans all the objects in this database that need to be cleaned after each schema.- Parameters:
schemas- The list of schemas managed by MigrateDB.- Throws:
SQLException- when the clean failed.
-
getAllSchemas
- Specified by:
getAllSchemasin interfaceDatabase<C extends Connection<?>>
-