Interface TableDefinition<R extends Record>


public interface TableDefinition<R extends Record>
A table to open with a schema version and migrations:
Table<Balance> balances = this.storage().define("balances", Balance.class)
    .version(2)
    .migrate(1, row -> new Balance(row.getLong("coins"), null))
    .open();
  • Method Summary

    Modifier and Type
    Method
    Description
    migrate(int from, Function<Row,R> migration)
    How to turn a row stored with schema version from into the current record.
    Creates the table, or checks the stored one against the record and migrates it.
    version(int version)
    Schema version of the record, at least 1.
  • Method Details

    • version

      TableDefinition<R> version(int version)
      Schema version of the record, at least 1. Default: 1.
    • migrate

      TableDefinition<R> migrate(int from, Function<Row,R> migration)
      How to turn a row stored with schema version from into the current record. Needed when the stored version is older than version(int) or the record changed in a way that cannot be applied without data.
    • open

      Table<R> open()
      Creates the table, or checks the stored one against the record and migrates it.
      Throws:
      StorageException - when the stored table does not match and no migration applies