Class DBTableSchema
java.lang.Object
com.inductiveautomation.ignition.gateway.db.schema.DBTableSchema
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA required column whose live declared type is incompatible with theDataTypethe schema expects to store there, grouped intocomparable type families.static final recordThe live declared type of an existing column, as reported byDatabaseMetaData.getColumns(String, String, String, String): the JDBCDATA_TYPE(Types) and the dialect'sTYPE_NAME. -
Constructor Summary
ConstructorsConstructorDescriptionDBTableSchema(String tableName) DBTableSchema(String tableName, DBTranslator translator) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumnsToTable(Connection conn, ColumnList columns) voidaddRequiredColumn(Column value) voidaddRequiredColumn(String name, DataType type) voidaddRequiredColumn(String name, DataType type, EnumSet<ColumnProperty> properties) voidcreateTable(Connection conn) Compares the live declared type of each required column that exists in the table against the type this schema expects to store there, and returns any column whose declared type is incompatible.getCasedColumnName(String column) Returns the given column name, but with the casing retrieved from the database.protected org.apache.log4j.LoggervoidinsertRequiredColumn(String name, DataType type, EnumSet<ColumnProperty> properties) refreshTableState(Connection conn) voidsetTranslator(DBTranslator value) voidverifyAndUpdate(Connection conn)
-
Constructor Details
-
DBTableSchema
-
DBTableSchema
-
-
Method Details
-
getLogger
protected org.apache.log4j.Logger getLogger() -
getCasedColumnName
-
findTypeMismatches
Compares the live declared type of each required column that exists in the table against the type this schema expects to store there, and returns any column whose declared type is incompatible. A column is accepted when its liveColumnTypeFamilymatches either the abstractDataType familyor the family the translator would emit for it (e.g. a SQLitetexttimestamp column), viaColumnTypeFamily.isCompatible(ColumnTypeFamily, ColumnTypeFamily, ColumnTypeFamily). Width/precision and benign dialect differences are ignored; only definite cross-family mismatches are reported.This is a read-only diagnostic: it neither alters the table nor throws on a mismatch — unlike
verifyAndUpdate(Connection), which only ever adds missing columns and never inspects types. Call it afterverifyAndUpdate(Connection)(orrefreshTableState(Connection)) has populated the live-type map; callers decide how to react to the returned mismatches. Columns absent from the table are skipped (they would have been added, or reported as missing, by the verify pass).- Returns:
- the incompatible columns, empty if every present required column has a compatible type
-
setTranslator
-
getTableName
-
addRequiredColumn
-
addRequiredColumn
-
addRequiredColumn
-
insertRequiredColumn
-
verifyAndUpdate
- Throws:
Exception
-
createTable
- Throws:
Exception
-
addColumnsToTable
- Throws:
Exception
-
refreshTableState
- Throws:
Exception
-