Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public static final class MigrationSet.Builder

  1. Object
  2. MigrationSet.Builder
Collects the migrations of a set.

Methods

public MigrationSet.Builder table(String table)Names the history table.
public MigrationSet.Builder sql(String version, String description, String script)Adds a versioned script that runs on every engine.
public MigrationSet.Builder sql(String version, String description, String dialect, String script)Adds a versioned script for one engine.
public MigrationSet.Builder repeatable(String description, String script)Adds a repeatable script: it runs after the versioned ones, and again whenever its text changes.
public MigrationSet.Builder repeatable(String description, String dialect, String script)Adds a repeatable script for one engine.
public MigrationSet.Builder java(String version, String description, JavaMigration migration)Adds a migration written in Java.
public MigrationSet.Builder java(String version, String description, String name, JavaMigration migration)Adds a migration written in Java and recorded under a name of its own.
public MigrationSet.Builder undo(String version, String description, String script)Marks the migration added last as running outside a transaction.
public MigrationSet.Builder undo(String version, String description, String dialect, String script)undo(String, String, String) for one engine only.
public MigrationSet.Builder callback(String event, String description, String dialect, String script)Adds a SQL callback: a script run at event, one of the constants of MigrationCallback.
public MigrationSet.Builder callback(MigrationCallback callback)Adds a Java callback; see MigrationCallback.
public MigrationSet.Builder compiledUndo(String version, String description, String scriptName, String dialect, boolean transactional, MigrationSource source, int id)A compiled undo script; see compiled.
public MigrationSet.Builder compiledCallback(String event, String description, String scriptName, String dialect, MigrationSource source, int id)A compiled SQL callback; see compiled.
public MigrationSet.Builder outsideTransaction()
public MigrationSet build()Builds the set.

Inherited methods

Method details

table

public MigrationSet.Builder table(String table)
Names the history table.

Parameters

table String
a plain identifier

Returns

this builder

sql

public MigrationSet.Builder sql(String version, String description, String script)
Adds a versioned script that runs on every engine.

Parameters

version String
the version, such as 3 or 2026.05.21.1
description String
what it does
script String
one or more SQL statements

Returns

this builder

sql

public MigrationSet.Builder sql(String version, String description, String dialect, String script)
Adds a versioned script for one engine. A version needs either one script for every engine or one per engine the application runs on.

Parameters

version String
the version
description String
what it does
dialect String
sqlite, postgresql or mysql, or null for every engine
script String
one or more SQL statements

Returns

this builder

repeatable

public MigrationSet.Builder repeatable(String description, String script)
Adds a repeatable script: it runs after the versioned ones, and again whenever its text changes. Views and seed data are the usual use.

Parameters

description String
what it does; repeatable scripts run in description order
script String
one or more SQL statements

Returns

this builder

repeatable

public MigrationSet.Builder repeatable(String description, String dialect, String script)
Adds a repeatable script for one engine.

Parameters

description String
what it does
dialect String
sqlite, postgresql or mysql, or null for every engine
script String
one or more SQL statements

Returns

this builder

java

public MigrationSet.Builder java(String version, String description, JavaMigration migration)
Adds a migration written in Java.

Parameters

version String
the version
description String
what it does
migration JavaMigration
the code to run

Returns

this builder

java

public MigrationSet.Builder java(String version, String description, String name, JavaMigration migration)

Adds a migration written in Java and recorded under a name of its own.

The history records the class name of a Java migration as its script. A class that provides several versions would be recorded under one name for all of them, and a run that reports what it applied would print that name once per version. Give each version a name that says which it is.

The name is what a person reads in the history and in the output of a run. Nothing is compared against it: a history written under another name – the class name, before a set started naming its versions – still validates.

Parameters

version String
the version
description String
what it does
name String
the name the history records as this migration’s script
migration JavaMigration
the code to run

Returns

this builder

undo

public MigrationSet.Builder undo(String version, String description, String script)
Marks the migration added last as running outside a transaction. A script that must manage its own, such as a SQLite table rebuild that switches foreign keys off, needs this.

Returns

this builder Adds the undo script of version, run by undo to take that migration back.

undo

public MigrationSet.Builder undo(String version, String description, String dialect, String script)
undo(String, String, String) for one engine only.

callback

public MigrationSet.Builder callback(String event, String description, String dialect, String script)
Adds a SQL callback: a script run at event, one of the constants of MigrationCallback. Callbacks of one event run in the order of their names.

callback

public MigrationSet.Builder callback(MigrationCallback callback)
Adds a Java callback; see MigrationCallback.

compiledUndo

public MigrationSet.Builder compiledUndo(String version, String description, String scriptName, String dialect, boolean transactional, MigrationSource source, int id)
A compiled undo script; see compiled.

compiledCallback

public MigrationSet.Builder compiledCallback(String event, String description, String scriptName, String dialect, MigrationSource source, int id)
A compiled SQL callback; see compiled.

outsideTransaction

public MigrationSet.Builder outsideTransaction()

build

public MigrationSet build()
Builds the set.

Returns

the set, ready to register or to hand to a migrator