Class TopiaMigrationServiceExecutor
- java.lang.Object
-
- org.nuiton.topia.service.migration.TopiaMigrationServiceExecutor
-
- All Implemented Interfaces:
Closeable,AutoCloseable,MigrationVersionResourceExecutor
public class TopiaMigrationServiceExecutor extends Object implements MigrationVersionResourceExecutor
Default implementation ofMigrationVersionResourceExecutorwith extra methods used byTopiaMigrationService.migrateVersion(TopiaMigrationServiceContext, Version).This executor is pass to each version to migrate.
Created by tchemit on 06/05/2018.
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringclassifierprotected StringlogPrefixprotected PathscriptForVersionprotected MigrationVersionResourceScriptLayoutscriptLayoutprotected TopiaSqlDllSupportsqlDllSupportprotected TopiaSqlSupportsqlSupportprotected org.nuiton.version.Versionversionprotected SqlScriptWriterwriter
-
Constructor Summary
Constructors Modifier Constructor Description protectedTopiaMigrationServiceExecutor(org.nuiton.version.Version version, MigrationVersionResourceScriptLayout scriptLayout, TopiaSqlSupport sqlSupport, String classifier, Path scriptsPath, Map<String,String> scriptVariables)protectedTopiaMigrationServiceExecutor(org.nuiton.version.Version version, MigrationVersionResourceScriptLayout scriptLayout, TopiaSqlSupport sqlSupport, String classifier, TopiaSqlDllSupport sqlDllSupport, Path scriptForVersion, Map<String,String> scriptVariables, String logPrefix)
-
Method Summary
-
-
-
Field Detail
-
version
protected final org.nuiton.version.Version version
-
sqlSupport
protected final TopiaSqlSupport sqlSupport
-
sqlDllSupport
protected final TopiaSqlDllSupport sqlDllSupport
-
scriptLayout
protected final MigrationVersionResourceScriptLayout scriptLayout
-
classifier
protected final String classifier
-
scriptForVersion
protected final Path scriptForVersion
-
writer
protected final SqlScriptWriter writer
-
logPrefix
protected final String logPrefix
-
-
Constructor Detail
-
TopiaMigrationServiceExecutor
protected TopiaMigrationServiceExecutor(org.nuiton.version.Version version, MigrationVersionResourceScriptLayout scriptLayout, TopiaSqlSupport sqlSupport, String classifier, Path scriptsPath, Map<String,String> scriptVariables)
-
TopiaMigrationServiceExecutor
protected TopiaMigrationServiceExecutor(org.nuiton.version.Version version, MigrationVersionResourceScriptLayout scriptLayout, TopiaSqlSupport sqlSupport, String classifier, TopiaSqlDllSupport sqlDllSupport, Path scriptForVersion, Map<String,String> scriptVariables, String logPrefix)
-
-
Method Detail
-
toFinalize
public TopiaMigrationServiceExecutor toFinalize()
-
getLogPrefix
public String getLogPrefix()
-
getScriptForVersion
public Path getScriptForVersion()
-
writeSql
public void writeSql(String sql)
- Specified by:
writeSqlin interfaceMigrationVersionResourceExecutor
-
addScript
public void addScript(String rank, String prefix)
- Specified by:
addScriptin interfaceMigrationVersionResourceExecutor
-
findSingleResult
public <O> O findSingleResult(TopiaSqlQuery<O> query)
- Specified by:
findSingleResultin interfaceMigrationVersionResourceExecutor
-
findMultipleResult
public <O> List<O> findMultipleResult(TopiaSqlQuery<O> query)
- Specified by:
findMultipleResultin interfaceMigrationVersionResourceExecutor
-
findMultipleResultAstSet
public <O> Set<O> findMultipleResultAstSet(TopiaSqlQuery<O> query)
- Specified by:
findMultipleResultAstSetin interfaceMigrationVersionResourceExecutor
-
dropSchema
public void dropSchema(String schemaName)
- Specified by:
dropSchemain interfaceMigrationVersionResourceExecutor
-
dropTable
public void dropTable(String schemaName, String tableName)
- Specified by:
dropTablein interfaceMigrationVersionResourceExecutor
-
doSqlWork
public void doSqlWork(TopiaSqlWork sqlWork)
- Specified by:
doSqlWorkin interfaceMigrationVersionResourceExecutor
-
getTopiaIds
public Set<String> getTopiaIds(String tableName)
- Specified by:
getTopiaIdsin interfaceMigrationVersionResourceExecutor
-
getUniqueConstraintName
public String getUniqueConstraintName(String tableName, String columnName)
- Specified by:
getUniqueConstraintNamein interfaceMigrationVersionResourceExecutor
-
getFirstTableUniqueConstraintName
public String getFirstTableUniqueConstraintName(String tableName)
- Specified by:
getFirstTableUniqueConstraintNamein interfaceMigrationVersionResourceExecutor
-
getConstraintNames
public Set<String> getConstraintNames(String tableName)
- Specified by:
getConstraintNamesin interfaceMigrationVersionResourceExecutor
-
getForeignKeyConstraintNames
public Set<String> getForeignKeyConstraintNames(String tableName)
- Specified by:
getForeignKeyConstraintNamesin interfaceMigrationVersionResourceExecutor
-
getForeignKeyConstraintName
public String getForeignKeyConstraintName(String schemaName, String tableName, String columnName, boolean mustExists)
- Specified by:
getForeignKeyConstraintNamein interfaceMigrationVersionResourceExecutor
-
getUniqueKeyConstraintNames
public Set<String> getUniqueKeyConstraintNames(String tableName)
- Specified by:
getUniqueKeyConstraintNamesin interfaceMigrationVersionResourceExecutor
-
removeFK
public void removeFK(String tableName)
- Specified by:
removeFKin interfaceMigrationVersionResourceExecutor
-
removeFK
public void removeFK(String schemaName, String tableName, String columnName)
- Specified by:
removeFKin interfaceMigrationVersionResourceExecutor
-
removeFKIfExists
public void removeFKIfExists(String schemaName, String tableName, String columnName)
- Specified by:
removeFKIfExistsin interfaceMigrationVersionResourceExecutor
-
removePKIfExists
public void removePKIfExists(String schemaName, String tableName)
- Specified by:
removePKIfExistsin interfaceMigrationVersionResourceExecutor
-
removeUK
public void removeUK(String tableName)
- Specified by:
removeUKin interfaceMigrationVersionResourceExecutor
-
executeForPG
public void executeForPG(Consumer<MigrationVersionResourceExecutor> consumer)
- Specified by:
executeForPGin interfaceMigrationVersionResourceExecutor
-
executeForH2
public void executeForH2(Consumer<MigrationVersionResourceExecutor> consumer)
- Specified by:
executeForH2in interfaceMigrationVersionResourceExecutor
-
flush
public long flush() throws IOException- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
loadScript
protected void loadScript(org.nuiton.version.Version version, String rank, String prefix)
-
getScriptLocation
protected URL getScriptLocation(org.nuiton.version.Version version, String rank, String prefix, String classifier)
-
isH2
protected boolean isH2()
-
isPG
protected boolean isPG()
-
-