You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project was derived from [apgdiff](https://github.com/fordfrog/apgdiff) project. At this point it is almost fully rewritten according to our needs.
39
91
Primary packages of this module are:
40
92
41
-
-`org.pgcodekeeper.core.schema` - contains classes that describe SQL objects. Each class contains object properties, creation SQL code generator, object comparison logic and ALTER code generator. Notable classes:
42
-
-`PgStatement` - all object classes must be derived from this one. Defines main API for working with objects.
43
-
-`PgDatabase` - root class for every loaded database schema.
44
-
-`GenericColumn` - generic reference to any object (used to be a column reference).
93
+
94
+
-`org.pgcodekeeper.core.api` - high-level API classes for database operations.
95
+
-`org.pgcodekeeper.core.schema` - contains classes that describe SQL objects. Each class contains object properties, creation SQL code generator, object comparison logic and ALTER code generator.
45
96
-`org.pgcodekeeper.core.schema.meta` - simplified SQL object classes for database structure serialization.
46
97
-`org.pgcodekeeper.core.schema.meta` (resources) - serialized descriptions of PostgreSQL's system objects (built using JdbcSystemLoader).
-`AntlrParser` - factory methods for parser creation and parallel parser operations.
54
-
-`QNameParser` - utility class for parsing and splitting qualified names.
55
-
-`ScriptParser` - simple parser that splits statements for later execution.
56
-
-`Custom(T)SQLParserListener` - main entry point for parsing SQLs into schema objects.
57
-
-`org.pgcodekeeper.core.parsers.antlr.statements` - processor classes that create schema objects based on parser-read data. Notable classes:
58
-
-`ParserAbstract` - common base class for all processors.
101
+
-`org.pgcodekeeper.core.parsers.antlr` - generated ANTLR4 parser code, plus utility parser classes.
102
+
-`org.pgcodekeeper.core.parsers.antlr.statements` - processor classes that create schema objects based on parser-read data.
59
103
-`org.pgcodekeeper.core.parsers.antlr.expr` - expression analysis classes: find dependencies in expressions and infer expression types for overloaded function call resolution.
60
104
-`org.pgcodekeeper.core.parsers.antlr.expr.launcher` - support for parallel expression analysis.
61
105
-`org.pgcodekeeper.core.formatter` - SQL and pl/pgsql code formatters.
62
-
-`org.pgcodekeeper.core.model.difftree` - classes representing and creating an object diff tree. Notable classes:
63
-
-`DbObjType` - enum of all SQL object types supported by the program.
64
-
-`TreeElement` - a node in an object diff tree.
65
-
-`DiffTree` - object diff tree factory.
66
-
-`TreeFlattener` - filters and flattens the tree into a list of nodes according to requested parameters.
67
-
-`org.pgcodekeeper.core.model.graph` - object dependency graph classes, built using JGraphT library. Notable classes:
68
-
-`DepcyGraph` - the dependency graph and its builder.
69
-
-`DepcyResolver` - main script building algorithm. Creates a list of `StatementAction`s according to requested object changes and object dependencies.
70
-
-`DepcyTreeExtender` - extends an object diff tree according to object dependencies.
71
-
-`DepcyWriter` - prints a dependency tree for an object.
72
-
-`org.pgcodekeeper.core.model.exporter` - classes that save and update the project files on disk. Notable classes:
73
-
-`ModelExporter`, `MsModelExporter`, `AbstractModelExporter` - exporters for PG and MS projects and their common abstract part.
74
-
-`OverridesModelExporter` - exports project structure containing only permission overrides.
106
+
-`org.pgcodekeeper.core.model.difftree` - classes representing and creating an object diff tree.
107
+
-`org.pgcodekeeper.core.model.graph` - object dependency graph classes, built using JGraphT library.
108
+
-`org.pgcodekeeper.core.model.exporter` - classes that save and update the project files on disk.
75
109
-`org.pgcodekeeper.core.sql` - a categorized list of all PostgreSQL keywords. Generated from PostgreSQL source.
76
110
-`org.pgcodekeeper.core.ignoreparser` - builder for `IgnoreList`s.
77
-
-`org.pgcodekeeper.core` - main package containing general stuff: e.g. string constants, utils and general-purpose classes. Notable classes:
78
-
-`PgDiff` - entry point for database schema diff operations.
111
+
-`org.pgcodekeeper.core` - main package containing general stuff: e.g. string constants, utils and general-purpose classes.
79
112
-`src.main.antlr4.org.pgcodekeeper.core.parsers.antlr.generated` - sources for ANTLR4 parsers. We maintain parsers for PostgreSQL, pl/pgsql, T-SQL, and also our custom Ignore Lists and PostgreSQL ACLs syntax.
80
113
These need to be built using your preferred ANTLR4 builder into `ru.taximaxim.codekeeper.core.parsers.antlr` package.
81
114
82
-
Majority of tests are here.
115
+
Majority of tests are here.
83
116
84
-
-`org.pgcodekeeper.core` - `PgDiffTest`, `MsDiffTest` - these test cases load old and new database schemas, generate a migration script and compare it to the expected diff file.
117
+
-`org.pgcodekeeper.core.api` - integration tests for the high-level API operations (diff, export, update) using real test databases and projects.
118
+
-`org.pgcodekeeper.core` - these test cases load old and new database schemas, generate a migration script and compare it to the expected diff file.
85
119
-`org.pgcodekeeper.core.depcies` - tests here work similarly to simple diff tests above, except the concept of "user selection" is added. Migration script is built only with objects in `usr` files as starting points, other objects must be added to the script via dependency mechanism.
86
-
-`org.pgcodekeeper.core.loader` - `PgAntlrLoaderTest`, `MsAntlrLoaderTest` - these tests load simple schemas from files and compare loaded PgDatabase objects with predefined ones.
120
+
-`org.pgcodekeeper.core.loader` - these tests load simple schemas from files and compare loaded AbstractDatabase objects with predefined ones.
87
121
-`org.pgcodekeeper.core.parsers` - these tests simply parse test pieces of code (taken from PostgreSQL source) to verify parser validity.
88
122
-`org.pgcodekeeper.core.parsers.antlr.expr` - these tests verify expression analysis and type inference mechanism.
89
123
-`org.pgcodekeeper.core.model.exporter` - these test update exported project directories and verify which files have actually been changed.
@@ -92,11 +126,11 @@ Majority of tests are here.
92
126
93
127
General program lifecycle goes as follows:
94
128
1.`ISettings` object is filled with operation parameters.
95
-
2.`PgDatabase`s are loaded from requested sources, including their libraries and privilege overrides. Ignored schemas are skipped at this step.
129
+
2.`AbstractDatabase`s are loaded from requested sources, including their libraries and privilege overrides. Ignored schemas are skipped at this step.
96
130
1. During the load dependencies of each object are found and recorded. Expressions are also analyzed to extract their dependencies including overloaded function calls.
97
131
2. All parser and expression analysis operations are run in parallel using `AntlrParser.ANTLR_POOL` thread pool to speed up the process. Parallel operations are serialized by calling `finishLoaders` at the end of each loading process.
98
-
3. The diff tree (represented by root `TreeElement`) is created by comparing two `PgDatabase`s. In GUI this is then shown to the user to assess the situation and choose objects to work with.
132
+
3. The diff tree (represented by root `TreeElement`) is created by comparing two `AbstractDatabase`s.
99
133
4. The diff tree, now containing "user selection", is used to selectively update project files on disk, or to generate a migration script.
100
134
5. In latter case, each "selected" TreeElement is passed to `DepcyResolver` to generate script actions fulfilling the requested change, including actions on dependent objects. To do this, JGraphT object dependency graphs are built using dependency information found at the loading stage.
101
135
6. Generated actions are now converted into SQL code with some last-moment post-processing and filtering.
102
-
7. Generated SQL script is written to a file/stdout or shown in the GUI for user to review and run on their database.
136
+
7. Generated SQL script is returned as a String for user to review and run on their database.
0 commit comments