generated from liquibase/liquibase-extension-example
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59a17e2
commit dc8439a
Showing
5 changed files
with
81 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...liquibase/ext/databricks/diff/output/changelog/MissingTableChangeGeneratorDatabricks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package liquibase.ext.databricks.diff.output.changelog; | ||
|
||
import liquibase.change.Change; | ||
import liquibase.change.core.CreateTableChange; | ||
import liquibase.database.Database; | ||
import liquibase.diff.output.DiffOutputControl; | ||
import liquibase.diff.output.changelog.ChangeGeneratorChain; | ||
import liquibase.diff.output.changelog.core.MissingTableChangeGenerator; | ||
import liquibase.ext.databricks.change.createTable.CreateTableChangeDatabricks; | ||
import liquibase.ext.databricks.change.createTable.ExtendedTableProperties; | ||
import liquibase.ext.databricks.database.DatabricksDatabase; | ||
import liquibase.structure.DatabaseObject; | ||
import liquibase.structure.core.Table; | ||
|
||
public class MissingTableChangeGeneratorDatabricks extends MissingTableChangeGenerator { | ||
|
||
|
||
@Override | ||
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) { | ||
if (database instanceof DatabricksDatabase && Table.class.isAssignableFrom(objectType)) { | ||
return PRIORITY_DATABASE; | ||
} else { | ||
return PRIORITY_NONE; | ||
} | ||
} | ||
|
||
@Override | ||
public Change[] fixMissing(DatabaseObject missingObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, | ||
ChangeGeneratorChain chain) { | ||
Change[] changes = super.fixMissing(missingObject, control, referenceDatabase, comparisonDatabase, chain); | ||
if (changes == null || changes.length == 0) { | ||
return changes; | ||
} | ||
ExtendedTableProperties extendedTableProperties = new ExtendedTableProperties( | ||
missingObject.getAttribute("Location", String.class), | ||
missingObject.getAttribute("tblProperties", String.class)); | ||
|
||
changes[0] = getCreateTableChangeDatabricks(extendedTableProperties, changes); | ||
return changes; | ||
} | ||
|
||
private CreateTableChangeDatabricks getCreateTableChangeDatabricks(ExtendedTableProperties extendedTableProperties, Change[] changes) { | ||
CreateTableChange temp = (CreateTableChange) changes[0]; | ||
CreateTableChangeDatabricks createTableChangeDatabricks = new CreateTableChangeDatabricks(); | ||
createTableChangeDatabricks.setColumns(temp.getColumns()); | ||
createTableChangeDatabricks.setTableType(temp.getTableType()); | ||
createTableChangeDatabricks.setCatalogName(temp.getCatalogName()); | ||
createTableChangeDatabricks.setSchemaName(temp.getSchemaName()); | ||
createTableChangeDatabricks.setTableName(temp.getTableName()); | ||
createTableChangeDatabricks.setTablespace(temp.getTablespace()); | ||
createTableChangeDatabricks.setRemarks(temp.getRemarks()); | ||
createTableChangeDatabricks.setIfNotExists(temp.getIfNotExists()); | ||
createTableChangeDatabricks.setRowDependencies(temp.getRowDependencies()); | ||
|
||
createTableChangeDatabricks.setExtendedTableProperties(extendedTableProperties); | ||
return createTableChangeDatabricks; | ||
} | ||
|
||
protected CreateTableChange createCreateTableChange() { | ||
return new CreateTableChangeDatabricks(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/resources/META-INF/services/liquibase.diff.output.changelog.ChangeGenerator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
liquibase.ext.databricks.diff.output.changelog.MissingTableChangeGeneratorDatabricks |