@pturmel yesterday when this topic came back to mind (still having issues with it) I realized I never posted what the error was. Here I am just doing a test to show what I am seeing:
Current Persistent Record Columns
Add one dummy field
Verify schema and maybe create are defined and called from gateway hook setup:
private void verifySchema(GatewayContext context) {
try {
context.getSchemaUpdater().updatePersistentRecords(KafkaSettingsRecord.META);
} catch (SQLException e) {
log.error("Error verifying persistent record schemas for KafkaConnect records.", e);
}
}
public void maybeCreateKafkaSettings(GatewayContext context) {
log.trace("Attempting to create Kafka Settings Record");
try {
KafkaSettingsRecord settingsRecord = context.getLocalPersistenceInterface().createNew(KafkaSettingsRecord.META);
settingsRecord.setId(0L);
settingsRecord.setBrokerList("127.0.0.1:9092");
settingsRecord.setTagHistoryTopic("ignition-PROD-tag-history");
settingsRecord.setEnabled(false);
settingsRecord.setUseStoreAndFwd(false);
settingsRecord.setUseSSL(false);
settingsRecord.setAlarmsTopic("ignition-PROD-alarm-event");
settingsRecord.setDefaultAlarmPriority();
settingsRecord.setSource("");
settingsRecord.setAlarmsEnabled(false);
settingsRecord.setAuditTopic("ignition-PROD-audit-event");
settingsRecord.setAuditEnabled(false);
settingsRecord.setScriptingEnabled(false);
settingsRecord.setEquipmentStateTopic("ignition-PROD-equipment-state");
settingsRecord.setDispositionTopic("ignition-PROD-disposition");
settingsRecord.setTest("Hey hey");
// This doesn't override existing settings, it only sets the above if there is no existing settings
context.getSchemaUpdater().ensureRecordExists(settingsRecord);
} catch (Exception e) {
log.error("Failed to establish Kafka Record exists", e);
}
log.trace("Kafka Settings Record Established");
}
After installing the updated module with the added field, the module status goes to faulted:
There are 3 messages about it in the log:
The 1st one about InternalDatabaseManager
is missing the test field.
The 2nd is is about non null constraint failed. I believe this may be the issue but not sure what is the correct action to make it non-null
org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_NOTNULL] A NOT NULL constraint failed (NOT NULL constraint failed: KAFKASETTINGSRECORD.TEST)
Finally, the 3rd message is about the fact that it failed to update the record:
simpleorm.utils.SException$Jdbc: Preparing 'SELECT KafkaSettingsRecord.KafkaSettingsRecord_ID, KafkaSettingsRecord.Brokers, KafkaSettingsRecord.TagHistoryTopic, KafkaSettingsRecord.Enabled, KafkaSettingsRecord.UseStoreAndFwd, KafkaSettingsRecord.UseSSL, KafkaSettingsRecord.AlarmsTopic, KafkaSettingsRecord.MinimumPriority, KafkaSettingsRecord.Source, KafkaSettingsRecord.DispPath, KafkaSettingsRecord.SrcPath, KafkaSettingsRecord.AlarmsEnabled, KafkaSettingsRecord.AuditTopic, KafkaSettingsRecord.AuditEnabled, KafkaSettingsRecord.ScriptingEnabled, KafkaSettingsRecord.DispositionTopic, KafkaSettingsRecord.EquipmentStateTopic, KafkaSettingsRecord.Test FROM KafkaSettingsRecord WHERE KafkaSettingsRecord_ID = ? '
So the issue seems to be about NOT NULL.
Nick