Class PgCodeKeeperApi

java.lang.Object
org.pgcodekeeper.core.api.PgCodeKeeperApi

public final class PgCodeKeeperApi extends Object
Main API class for pgCodeKeeper database operations.
  • Method Details

    • diff

      public static String diff(ISettings settings, AbstractDatabase oldDb, AbstractDatabase newDb) throws IOException, InterruptedException
      Compares two databases and generates a migration script.
      Parameters:
      settings - ISettings object
      oldDb - the old database version to compare from
      newDb - the new database version to compare to
      Returns:
      the generated migration script as a string
      Throws:
      IOException - if I/O operations fail
      InterruptedException - if the thread is interrupted during the operation
    • diff

      public static String diff(ISettings settings, AbstractDatabase oldDb, AbstractDatabase newDb, Collection<String> ignoreLists) throws IOException, InterruptedException
      Compares two databases and generates a migration script with filtering.
      Parameters:
      settings - ISettings object
      oldDb - the old database version to compare from
      newDb - the new database version to compare to
      ignoreLists - collection of paths to files containing objects to ignore
      Returns:
      the generated migration script as a string
      Throws:
      IOException - if I/O operations fail or ignore list file cannot be read
      InterruptedException - if the thread is interrupted during the operation
    • diff

      public static String diff(ISettings settings, AbstractDatabase oldDb, AbstractDatabase newDb, List<Map.Entry<PgStatement,PgStatement>> additionalDependenciesOldDb, List<Map.Entry<PgStatement,PgStatement>> additionalDependenciesNewDb, Collection<String> ignoreLists) throws IOException, InterruptedException
      Compares two databases and generates a migration script with filtering and additional dependencies.
      Parameters:
      settings - ISettings object
      oldDb - the old database version to compare from
      newDb - the new database version to compare to
      additionalDependenciesOldDb - additional dependencies in old database
      additionalDependenciesNewDb - additional dependencies in new database
      ignoreLists - collection of paths to files containing objects to ignore
      Returns:
      the generated migration script as a string
      Throws:
      IOException - if I/O operations fail or ignore list file cannot be read
      InterruptedException - if the thread is interrupted during the operation
    • diff

      public static String diff(ISettings settings, TreeElement root, AbstractDatabase oldDb, AbstractDatabase newDb, List<Map.Entry<PgStatement,PgStatement>> additionalDependenciesOldDb, List<Map.Entry<PgStatement,PgStatement>> additionalDependenciesNewDb, Collection<String> ignoreLists) throws IOException
      Compares two databases and generates a migration script with filtering and additional dependencies.
      Parameters:
      settings - ISettings object
      root - root element of tree
      oldDb - the old database version to compare from
      newDb - the new database version to compare to
      additionalDependenciesOldDb - additional dependencies in old database
      additionalDependenciesNewDb - additional dependencies in new database
      ignoreLists - collection of paths to files containing objects to ignore
      Returns:
      the generated migration script as a string
      Throws:
      IOException - if I/O operations fail or ignore list file cannot be read
    • export

      public static void export(ISettings settings, AbstractDatabase dbToExport, String exportTo) throws PgCodekeeperException, IOException, InterruptedException
      Exports database schema to project files.
      Parameters:
      settings - ISettings object
      dbToExport - the database to export
      exportTo - path to the target project directory
      Throws:
      IOException - if I/O operations fail, if export directory does not exist, if export directory is not empty or if path is a file
      InterruptedException - if the thread is interrupted during the operation
      PgCodekeeperException
    • export

      public static void export(ISettings settings, AbstractDatabase dbToExport, String exportTo, Collection<String> ignoreLists, IMonitor monitor) throws IOException, InterruptedException
      Exports database schema to project files with filtering and progress tracking.
      Parameters:
      settings - ISettings object
      dbToExport - the database to export
      exportTo - path to the target project directory
      ignoreLists - collection of paths to files containing objects to ignore
      monitor - progress monitor for tracking the operation
      Throws:
      IOException - if I/O operations fail, if export directory does not exist, if export directory is not empty, if path is a file, or if ignore list file cannot be read
      InterruptedException - if the thread is interrupted during the operation
    • update

      public static void update(ISettings settings, AbstractDatabase oldDb, AbstractDatabase newDb, String projectToUpdate) throws PgCodekeeperException, IOException, InterruptedException
      Updates project with changes from database.
      Parameters:
      settings - ISettings object
      oldDb - the old database version
      newDb - the new database version with changes
      projectToUpdate - path to the project directory to update
      Throws:
      PgCodekeeperException - if update operation fails or if parsing errors occur
      IOException - if I/O operations fail, if project directory does not exist or if path is a file
      InterruptedException - if the thread is interrupted during the operation
    • update

      public static void update(ISettings settings, AbstractDatabase oldDb, AbstractDatabase newDb, String projectToUpdate, Collection<String> ignoreLists, IMonitor monitor) throws PgCodekeeperException, IOException, InterruptedException
      Updates project with changes from database with filtering and progress tracking.
      Parameters:
      settings - ISettings object
      oldDb - the old database version
      newDb - the new database version with changes
      projectToUpdate - path to the project directory to update
      ignoreLists - collection of paths to files containing objects to ignore
      monitor - progress monitor for tracking the operation
      Throws:
      PgCodekeeperException - if update operation fails or if parsing errors occur
      IOException - if I/O operations fail, if project directory does not exist, if path is a file, or if ignore list files cannot be read
      InterruptedException - if the thread is interrupted during the operation