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 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 name
      type - the column type
      size - 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 name
      columnName - the new column name
      type - the column type
      size - size (can be null)
      nullable - whether allows null
      defaultValue - the default value
    • dropColumn

      void dropColumn(String tableName, String columnName)
      Drop a column from a table.
      Parameters:
      tableName - the table name
      columnName - the column to drop
    • renameColumn

      void renameColumn(String tableName, String oldName, String newName)
      Rename a column.
      Parameters:
      tableName - the table name
      oldName - the current column name
      newName - the new column name
    • alterColumnType

      void alterColumnType(String tableName, String columnName, ColumnType newType, Integer newSize)
      Change a column's type.
      Parameters:
      tableName - the table name
      columnName - the column name
      newType - the new type
      newSize - new size (can be null)
    • createIndex

      void createIndex(String tableName, boolean unique, String... columns)
      Create an index.
      Parameters:
      tableName - the table name
      unique - whether the index is unique
      columns - the columns to index
    • dropIndex

      void dropIndex(String tableName, String... columns)
      Drop an index.
      Parameters:
      tableName - the table name
      columns - the columns of the index
    • renameTable

      void renameTable(String oldName, String newName)
      Rename a table.
      Parameters:
      oldName - the current table name
      newName - the new table name
    • 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 name
      entityClass - the entity class
      migrator - function to process each entity