Class ModelExporter
java.lang.Object
org.pgcodekeeper.core.model.exporter.ModelExporter
- Direct Known Subclasses:
OverridesModelExporter
Exports database model as directory tree with SQL files containing object definitions.
Supports full, partial, and project exports with configurable encoding and database type support.
For historical reasons we expect a filtered user-selection-only list in exportPartial() but we use the new
API TreeElement.isSelected() for selection checks instead of calling Collection.contains(Object) for
performance reasons.
- Author:
- Alexander Levsha
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionModelExporter(Path outDir, AbstractDatabase db, DatabaseType databaseType, String sqlEncoding, ISettings settings) Creates a new ModelExporter for full database export.ModelExporter(Path outDir, AbstractDatabase newDb, AbstractDatabase oldDb, DatabaseType databaseType, Collection<TreeElement> changedObjects, String sqlEncoding, ISettings settings) Creates a new ModelExporter for partial or project export. -
Method Summary
Modifier and TypeMethodDescriptionvoidExports the complete database schema to directory structure.voidExports only changed objects based on comparison between old and new schemas.voidExports selected objects as a new project structure.static StringgetExportedFilename(PgStatement statement) Gets the exported filename for a database statement.static StringgetExportedFilenameSql(String name) Gets the SQL filename with .sql extension.static PathGets the relative file path for a database statement within project structure.static voidwriteProjVersion(Path path) Writes project version marker file.
-
Field Details
-
GROUP_DELIMITER
- See Also:
-
-
Constructor Details
-
ModelExporter
public ModelExporter(Path outDir, AbstractDatabase db, DatabaseType databaseType, String sqlEncoding, ISettings settings) Creates a new ModelExporter for full database export.- Parameters:
outDir- output directory, should be empty or not existdb- database to exportdatabaseType- database type for directory structuresqlEncoding- SQL file encodingsettings- export settings
-
ModelExporter
public ModelExporter(Path outDir, AbstractDatabase newDb, AbstractDatabase oldDb, DatabaseType databaseType, Collection<TreeElement> changedObjects, String sqlEncoding, ISettings settings) Creates a new ModelExporter for partial or project export.- Parameters:
outDir- output directorynewDb- new database schemaoldDb- old database schema, can be null for project exportdatabaseType- database type for directory structurechangedObjects- collection of changed objectssqlEncoding- SQL file encodingsettings- export settings
-
-
Method Details
-
exportFull
Exports the complete database schema to directory structure. Creates output directory and exports all database objects as SQL files.- Throws:
IOException- if export operation fails
-
exportPartial
Exports only changed objects based on comparison between old and new schemas. Handles object additions, deletions, and modifications.- Throws:
IOException- if export operation failsPgCodekeeperException- if old database is null or directory issues occur
-
exportProject
Exports selected objects as a new project structure. Creates clean directory structure with only specified objects.- Throws:
IOException- if export operation fails
-
getExportedFilename
Gets the exported filename for a database statement.- Parameters:
statement- the database statement- Returns:
- sanitized filename suitable for file system
-
getExportedFilenameSql
Gets the SQL filename with .sql extension.- Parameters:
name- the base name- Returns:
- filename with .sql extension
-
writeProjVersion
Writes project version marker file.- Parameters:
path- the path to write version file- Throws:
IOException- if writing fails
-
getRelativeFilePath
Gets the relative file path for a database statement within project structure.- Parameters:
st- the database statement- Returns:
- relative path for the statement's file
-