2222import org .pgcodekeeper .core .model .difftree .*;
2323import org .pgcodekeeper .core .model .exporter .ModelExporter ;
2424import org .pgcodekeeper .core .schema .AbstractDatabase ;
25+ import org .pgcodekeeper .core .schema .PgStatement ;
2526import org .pgcodekeeper .core .settings .ISettings ;
2627import org .pgcodekeeper .core .monitor .IMonitor ;
2728import org .pgcodekeeper .core .utils .ProjectUpdater ;
3132import java .util .Collection ;
3233import java .util .Collections ;
3334import java .util .List ;
35+ import java .util .Map ;
3436
3537/**
3638 * Main API class for pgCodeKeeper database operations.
@@ -48,7 +50,7 @@ public final class PgCodeKeeperApi {
4850 * @throws InterruptedException if the thread is interrupted during the operation
4951 */
5052 public static String diff (ISettings settings , AbstractDatabase oldDb , AbstractDatabase newDb )
51- throws PgCodekeeperException , IOException , InterruptedException {
53+ throws IOException , InterruptedException {
5254 return diff (settings , oldDb , newDb , Collections .emptyList ());
5355 }
5456
@@ -63,10 +65,63 @@ public static String diff(ISettings settings, AbstractDatabase oldDb, AbstractDa
6365 * @throws IOException if I/O operations fail or ignore list file cannot be read
6466 * @throws InterruptedException if the thread is interrupted during the operation
6567 */
66- public static String diff (ISettings settings , AbstractDatabase oldDb , AbstractDatabase newDb ,
67- Collection <String > ignoreLists ) throws IOException , InterruptedException {
68+ public static String diff (ISettings settings ,
69+ AbstractDatabase oldDb ,
70+ AbstractDatabase newDb ,
71+ Collection <String > ignoreLists )
72+ throws IOException , InterruptedException {
73+ return diff (settings , oldDb , newDb , null , null , ignoreLists );
74+ }
75+
76+ /**
77+ * Compares two databases and generates a migration script with filtering and additional dependencies.
78+ *
79+ * @param settings ISettings object
80+ * @param oldDb the old database version to compare from
81+ * @param newDb the new database version to compare to
82+ * @param additionalDependenciesOldDb additional dependencies in old database
83+ * @param additionalDependenciesNewDb additional dependencies in new database
84+ * @param ignoreLists collection of paths to files containing objects to ignore
85+ * @return the generated migration script as a string
86+ * @throws IOException if I/O operations fail or ignore list file cannot be read
87+ * @throws InterruptedException if the thread is interrupted during the operation
88+ */
89+ public static String diff (ISettings settings ,
90+ AbstractDatabase oldDb ,
91+ AbstractDatabase newDb ,
92+ List <Map .Entry <PgStatement , PgStatement >> additionalDependenciesOldDb ,
93+ List <Map .Entry <PgStatement , PgStatement >> additionalDependenciesNewDb ,
94+ Collection <String > ignoreLists )
95+ throws IOException , InterruptedException {
96+ TreeElement root = DiffTree .create (settings , oldDb , newDb );
97+ root .setAllChecked ();
98+ return diff (settings , root , oldDb , newDb , additionalDependenciesOldDb , additionalDependenciesNewDb , ignoreLists );
99+ }
100+
101+ /**
102+ * Compares two databases and generates a migration script with filtering and additional dependencies.
103+ *
104+ * @param settings ISettings object
105+ * @param root root element of tree
106+ * @param oldDb the old database version to compare from
107+ * @param newDb the new database version to compare to
108+ * @param additionalDependenciesOldDb additional dependencies in old database
109+ * @param additionalDependenciesNewDb additional dependencies in new database
110+ * @param ignoreLists collection of paths to files containing objects to ignore
111+ * @return the generated migration script as a string
112+ * @throws IOException if I/O operations fail or ignore list file cannot be read
113+ */
114+ public static String diff (ISettings settings ,
115+ TreeElement root ,
116+ AbstractDatabase oldDb ,
117+ AbstractDatabase newDb ,
118+ List <Map .Entry <PgStatement , PgStatement >> additionalDependenciesOldDb ,
119+ List <Map .Entry <PgStatement , PgStatement >> additionalDependenciesNewDb ,
120+ Collection <String > ignoreLists )
121+ throws IOException {
68122 IgnoreList ignoreList = IgnoreParser .parseLists (ignoreLists );
69- return new PgDiff (settings ).diff (oldDb , newDb , ignoreList );
123+ return new PgDiff (settings )
124+ .diff (root , oldDb , newDb , additionalDependenciesOldDb , additionalDependenciesNewDb , ignoreList );
70125 }
71126
72127 /**
@@ -101,8 +156,7 @@ public static void export(ISettings settings, AbstractDatabase dbToExport, Strin
101156 Collection <String > ignoreLists , IMonitor monitor )
102157 throws IOException , InterruptedException {
103158 IgnoreList ignoreList = IgnoreParser .parseLists (ignoreLists );
104- TreeElement root ;
105- root = DiffTree .create (settings , dbToExport , null , monitor );
159+ TreeElement root = DiffTree .create (settings , dbToExport , null , monitor );
106160 root .setAllChecked ();
107161
108162 List <TreeElement > selected = getSelectedElements (settings , root , ignoreList );
0 commit comments