MySQL/H2 Automatic Registration Fails

liridesco3 months ago

I am running Traccar Server 6.4 configured for a MySQL database connection, the server connects to the database OK and creates tables for the users (and all other tables) when I browse with MySQL browser.

I have set automatic registration of unknown devices, this appears to fail with the error of;

2024-09-03 21:31:30  WARN: Automatic registration failed - Cannot add or update a child row: a foreign key constraint fails ('traccar_live'.'tc_devices', CONSTRAINT 'fk_devices_groupid' FOREIGN KEY ('groupid') REFERENCES 'tc_groups' ('id') ON DELETE SET NULL) - SQLIntegrityConstraintViolationException (... < QueryBuilder:469 < DatabaseStorage:95 < ConnectionManager:181 < *:132 < BaseProtocolDecoder:135 < ...)

It was working with the H2 database but changing the configuration back to H2 now fails with a similar message saying;

2024-09-03 22:00:20  WARN: Automatic registration failed - Referential integrity constraint violation: "FK_DEVICES_GROUPID: PUBLIC.TC_DEVICES FOREIGN KEY(GROUPID) REFERENCES PUBLIC.TC_GROUPS(ID) (1)"; SQL statement:
INSERT INTO tc_devices(calendarId, uniqueId, phone, model, contact, category, disabled, expirationTime, name, groupId, attributes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23506-230] - JdbcSQLIntegrityConstraintViolationException (... < QueryBuilder:469 < DatabaseStorage:95 < ConnectionManager:181 < *:132 < BaseProtocolDecoder:135 < ...)

I have tried deleting the H2 database and letting Traccar re-create it and still have the same error.

Are there any solutions to my issue please?

liridesco3 months ago

Please ignore me - I was using registerUnknown.defaultGroupId to set a default group however in the changing of the databases I must have forgotten to re-create the group, now it has been created it works.