Interface PluginMigration.MigrationHelper
- Enclosing interface:
PluginMigration
public static interface PluginMigration.MigrationHelper
Helper interface for migration operations.
Provides methods for schema modifications that are typically needed during migrations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumn(String tableName, String columnName, ColumnType type, Integer size, boolean nullable) Add a column to an existing table.voidaddColumn(String tableName, String columnName, ColumnType type, Integer size, boolean nullable, String defaultValue) Add a column with a default value.voidalterColumnType(String tableName, String columnName, ColumnType newType, Integer newSize) Change a column's type.voidcreateIndex(String tableName, boolean unique, String... columns) Create an index.voiddropColumn(String tableName, String columnName) Drop a column from a table.voidDrop an index.Get the underlying database manager.<T> voidmigrateData(String tableName, Class<T> entityClass, PluginMigration.DataMigrator<T> migrator) Execute a data migration using the repository.voidrenameColumn(String tableName, String oldName, String newName) Rename a column.voidrenameTable(String oldName, String newName) Rename a table.
-
Method Details
-
getDatabaseManager
PluginDatabaseManager getDatabaseManager()Get the underlying database manager.- Returns:
- the database manager
-
addColumn
void addColumn(String tableName, String columnName, ColumnType type, Integer size, boolean nullable) Add a column to an existing table.- Parameters:
tableName- the table name (without prefix)columnName- the new column nametype- the column typesize- size for VARCHAR, etc. (can be null)nullable- whether the column allows null
-
addColumn
void addColumn(String tableName, String columnName, ColumnType type, Integer size, boolean nullable, String defaultValue) Add a column with a default value.- Parameters:
tableName- the table namecolumnName- the new column nametype- the column typesize- size (can be null)nullable- whether allows nulldefaultValue- the default value
-
dropColumn
-
renameColumn
-
alterColumnType
Change a column's type.- Parameters:
tableName- the table namecolumnName- the column namenewType- the new typenewSize- new size (can be null)
-
createIndex
-
dropIndex
-
renameTable
-
migrateData
<T> void migrateData(String tableName, Class<T> entityClass, PluginMigration.DataMigrator<T> migrator) Execute a data migration using the repository.This allows updating data as part of a migration.
- Type Parameters:
T- the entity type- Parameters:
tableName- the table nameentityClass- the entity classmigrator- function to process each entity
-