Interface TableDefinition<R extends Record>


@NonExtendable public interface TableDefinition<R extends Record>
A table to open with a schema version and migrations. It starts from the record's Schema and Migrate methods, if any; the calls below add to them:
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(@Range(from=1L,to=2147483647L) int version)
    Schema version of the record, at least 1.
  • Method Details

    • version

      TableDefinition<R> version(@Range(from=1L,to=2147483647L) int version)
      Schema version of the record, at least 1. Default: the record's Schema, or 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.
      Throws:
      IllegalArgumentException - when a migration from from exists already, also one from a Migrate method of the record
    • open

      @Blocking 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