Package com.enhancedechest.migration
Class DatabaseImportService
java.lang.Object
com.enhancedechest.migration.DatabaseImportService
Copies all EnhancedEchest data from an old database backend into the plugin's active backend
(
/ee import). The admin edits config.yml to the new (destination) backend, restarts
with no players online, and runs the import; this reads the old backend fully and writes it into the
new one in one transaction — no second restart needed.
The heavy work runs on the shared DB executor (never a region thread). Item bytes are copied verbatim (no (de)serialization), so cost is dominated by the batched destination writes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOutcome of an import run: how many rows landed in the destination. -
Constructor Summary
ConstructorsConstructorDescriptionDatabaseImportService(EnderChestStorage storage, PluginConfig config, org.slf4j.Logger logger, Path dataFolder) -
Method Summary
Modifier and TypeMethodDescriptionlongNumber of chest rows already in the destination; import requires this to be 0 (a fresh DB).importFrom(SourceSpec spec) Reads the source described byspecin full and writes it into the active destination in one transaction.booleanTrue ifspecpoints at the very database the plugin is actively running on — importing from the destination into itself makes no sense (and would trip the empty-destination guard), so the caller refuses it up front.
-
Constructor Details
-
DatabaseImportService
public DatabaseImportService(EnderChestStorage storage, PluginConfig config, org.slf4j.Logger logger, Path dataFolder)
-
-
Method Details
-
pointsAtActiveDatabase
True ifspecpoints at the very database the plugin is actively running on — importing from the destination into itself makes no sense (and would trip the empty-destination guard), so the caller refuses it up front. Compares stable identities (seeSourceSpec.identity(java.nio.file.Path)). -
destinationChestCount
public long destinationChestCount()Number of chest rows already in the destination; import requires this to be 0 (a fresh DB). -
importFrom
Reads the source described byspecin full and writes it into the active destination in one transaction. Synchronous — call on the DB executor. A missing source column surfaces as aSQLException("source schema outdated"); a duplicate key rolls the whole import back.- Throws:
Exception
-