Class SchemaJournalManager
-
- All Implemented Interfaces:
-
pro.fessional.wings.faceless.flywave.InteractiveManager
public final class SchemaJournalManager implements InteractiveManager<SchemaJournalManager.AskType>
Mange
log_updateandlog_deleteof$schemaJournalTableto auto create or delete Trigger.- Since:
2019-06-13
trydofor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumSchemaJournalManager.AskTypepublic final classSchemaJournalManager.JournalDdl
-
Field Summary
Fields Modifier and Type Field Description public final static StringPLAIN_NAMEpublic final static StringTABLE_NAMEpublic final static StringTABLE_BONEpublic final static StringTABLE_PKEY
-
Constructor Summary
Constructors Constructor Description SchemaJournalManager(Map<String, DataSource> plainDataSources, SqlStatementParser sqlStatementParser, SchemaDefinitionLoader schemaDefinitionLoader, SchemaJournalManager.JournalDdl journalDdl, String schemaJournalTable)
-
Method Summary
Modifier and Type Method Description BiConsumer<String, String>logWay(BiConsumer<String, String> func)How to log the runtime token and message Function<String, Boolean>askWay(Function<String, Boolean> func)How to confirm, pass message, return to continue or stop BooleanneedAsk(SchemaJournalManager.AskType ask, Boolean yes)Whether to confirm before undofinal UnitpublishUpdate(String table, Boolean enable, Long commitId)Apply trace table and its Update Trigger based on DDL templates. final UnitpublishDelete(String table, Boolean enable, Long commitId)Apply trace table and its Delete Trigger based on DDL templates. final UnitpublishInsert(String table, Boolean enable, Long commitId)Apply trace table and its Insert Trigger based on DDL templates. final UnitmanageTriggers(String table, Boolean drop)Check all triggers, and can ask whether to delete. final UnitcheckAndInitDdl(String table, Long commitId)Compare the SQL between in local and in database. -
-
Constructor Detail
-
SchemaJournalManager
SchemaJournalManager(Map<String, DataSource> plainDataSources, SqlStatementParser sqlStatementParser, SchemaDefinitionLoader schemaDefinitionLoader, SchemaJournalManager.JournalDdl journalDdl, String schemaJournalTable)
-
-
Method Detail
-
logWay
BiConsumer<String, String> logWay(BiConsumer<String, String> func)
How to log the runtime token and message
-
askWay
Function<String, Boolean> askWay(Function<String, Boolean> func)
How to confirm, pass message, return to continue or stop
-
needAsk
Boolean needAsk(SchemaJournalManager.AskType ask, Boolean yes)
Whether to confirm before
undo- Parameters:
ask- ask typeyes- whether to confirm, true by default- Returns:
old value
-
publishUpdate
final Unit publishUpdate(String table, Boolean enable, Long commitId)
Apply trace table and its Update Trigger based on DDL templates. Trace table, if it exists and has no data, recreate it. Trace table, if it exists and has data, ignore if the structure is the same, otherwise throw an error. Trigger, if trigger exists, delete and recreate it. If neither trace table nor trigger exists, create new one.
- Parameters:
table- plain tableenable- enable or disablecommitId- commit id of Journal
-
publishDelete
final Unit publishDelete(String table, Boolean enable, Long commitId)
Apply trace table and its Delete Trigger based on DDL templates. Trace table, if it exists and has no data, recreate it. Trace table, if it exists and has data, ignore if the structure is the same, otherwise throw an error. Trigger, if trigger exists, delete and recreate it. If neither trace table nor trigger exists, create new one.
- Parameters:
table- plain tableenable- enable or disablecommitId- commit id of Journal
-
publishInsert
final Unit publishInsert(String table, Boolean enable, Long commitId)
Apply trace table and its Insert Trigger based on DDL templates. Trace table, if it exists and has no data, recreate it. Trace table, if it exists and has data, ignore if the structure is the same, otherwise throw an error. Trigger, if trigger exists, delete and recreate it. If neither trace table nor trigger exists, create new one.
- Parameters:
table- plain tableenable- enable or disablecommitId- commit id of Journal
-
manageTriggers
final Unit manageTriggers(String table, Boolean drop)
Check all triggers, and can ask whether to delete.
- Parameters:
table- plain tabledrop- Whether to ask for drop, default false
-
checkAndInitDdl
final Unit checkAndInitDdl(String table, Long commitId)
Compare the SQL between in local and in database. If it does not exist, then save local to database. If it exists but the contents are not the same and has been
APPLYthen log error, otherwise update it.- Parameters:
table- plain tablecommitId- commit id of Journal
-
-
-
-