Class ActionsToScriptConverter

java.lang.Object
org.pgcodekeeper.core.model.graph.ActionsToScriptConverter

public final class ActionsToScriptConverter extends Object
Converts database action containers into executable SQL script statements. Processes CREATE, ALTER, and DROP operations in proper dependency order while handling special cases like data movement, table renaming, and partition tables.

This class is responsible for generating the final SQL migration script from resolved database actions. It handles complex scenarios including:

  • Data movement mode with temporary table creation and renaming
  • Joinable column alterations that can be combined into single ALTER TABLE statements
  • Partition table hierarchies and their dependencies
  • Microsoft SQL module refresh operations
  • Identity column preservation during data movement

The converter processes actions in dependency order and applies filtering based on user selections and configured object type restrictions.

  • Constructor Details

    • ActionsToScriptConverter

      public ActionsToScriptConverter(SQLScript script, Set<ActionContainer> actions, Set<PgStatement> toRefresh, AbstractDatabase oldDbFull, AbstractDatabase newDbFull)
      Creates a new ActionsToScriptConverter with the specified parameters. Initializes internal structures for data movement mode if enabled in settings.
      Parameters:
      script - the SQL script to populate with generated statements
      actions - set of resolved action containers representing database changes
      toRefresh - ordered set of statements requiring refresh operations (in reverse order)
      oldDbFull - the complete old database schema for reference and data movement
      newDbFull - the complete new database schema for reference and data movement
  • Method Details

    • fillScript

      public static void fillScript(SQLScript script, Set<ActionContainer> actions, Set<PgStatement> toRefresh, AbstractDatabase oldDbFull, AbstractDatabase newDbFull, List<TreeElement> selected)
      Fills the SQL script with statements based on resolved database actions. Creates a new ActionsToScriptConverter instance and processes all actions in right order.
      Parameters:
      script - the SQL script to populate with generated statements
      actions - set of resolved action containers representing database changes
      toRefresh - set of statements that need refreshing (for Microsoft SQL modules)
      oldDbFull - the complete old database schema for reference
      newDbFull - the complete new database schema for reference
      selected - list of user-selected tree elements for filtering actions