Class DatabaseImportService

java.lang.Object
com.enhancedechest.migration.DatabaseImportService

public final class DatabaseImportService extends Object
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.

  • Constructor Details

  • Method Details

    • pointsAtActiveDatabase

      public boolean pointsAtActiveDatabase(SourceSpec spec)
      True if spec points 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 (see SourceSpec.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

      public DatabaseImportService.Result importFrom(SourceSpec spec) throws Exception
      Reads the source described by spec in full and writes it into the active destination in one transaction. Synchronous — call on the DB executor. A missing source column surfaces as a SQLException ("source schema outdated"); a duplicate key rolls the whole import back.
      Throws:
      Exception