Class MigrationSet.Builder
java.lang.Object
com.codename1.migration.MigrationSet.Builder
- Enclosing class:
MigrationSet
Collects the migrations of a set.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the set.callback(MigrationCallback callback) Adds a Java callback; seeMigrationCallback.Adds a SQL callback: a script run atevent, one of the constants ofMigrationCallback.compiledCallback(String event, String description, String scriptName, String dialect, com.codename1.impl.migration.MigrationSource source, int id) A compiled SQL callback; seecompiled(String, String, String, String, int, boolean, MigrationSource, int).compiledUndo(String version, String description, String scriptName, String dialect, boolean transactional, com.codename1.impl.migration.MigrationSource source, int id) A compiled undo script; seecompiled(String, String, String, String, int, boolean, MigrationSource, int).java(String version, String description, JavaMigration migration) Adds a migration written in Java.java(String version, String description, String name, JavaMigration migration) Adds a migration written in Java and recorded under a name of its own.repeatable(String description, String script) Adds a repeatable script: it runs after the versioned ones, and again whenever its text changes.repeatable(String description, String dialect, String script) Adds a repeatable script for one engine.Adds a versioned script that runs on every engine.Adds a versioned script for one engine.Names the history table.Marks the migration added last as running outside a transaction.undo(String, String, String)for one engine only.
-
Method Details
-
table
Names the history table.- Parameters:
table- a plain identifier- Returns:
- this builder
-
sql
Adds a versioned script that runs on every engine.- Parameters:
version- the version, such as3or2026.05.21.1description- what it doesscript- one or more SQL statements- Returns:
- this builder
-
sql
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- the versiondescription- what it doesdialect-sqlite,postgresqlormysql, or null for every enginescript- one or more SQL statements- Returns:
- this builder
-
repeatable
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- what it does; repeatable scripts run in description orderscript- one or more SQL statements- Returns:
- this builder
-
repeatable
Adds a repeatable script for one engine.- Parameters:
description- what it doesdialect-sqlite,postgresqlormysql, or null for every enginescript- one or more SQL statements- Returns:
- this builder
-
java
Adds a migration written in Java.- Parameters:
version- the versiondescription- what it doesmigration- 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- the versiondescription- what it doesname- the name the history records as this migration's scriptmigration- the code to run- Returns:
- this builder
-
undo
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 byundoto take that migration back.
-
undo
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 atevent, one of the constants ofMigrationCallback. Callbacks of one event run in the order of their names. -
callback
Adds a Java callback; seeMigrationCallback. -
compiledUndo
public MigrationSet.Builder compiledUndo(String version, String description, String scriptName, String dialect, boolean transactional, com.codename1.impl.migration.MigrationSource source, int id) A compiled undo script; seecompiled(String, String, String, String, int, boolean, MigrationSource, int). -
compiledCallback
public MigrationSet.Builder compiledCallback(String event, String description, String scriptName, String dialect, com.codename1.impl.migration.MigrationSource source, int id) A compiled SQL callback; seecompiled(String, String, String, String, int, boolean, MigrationSource, int). -
outsideTransaction
-
build
Builds the set.- Returns:
- the set, ready to register or to hand to a migrator
-