-- Run once on production MySQL if the PHP patch has not run yet.
USE reads_attendance;

INSERT INTO settings (`key`, `value`) VALUES
  ('device_id', 'LOCAL-KIOSK-01'),
  ('api_key',   'local_api_key_123456')
ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);

INSERT INTO registered_devices (device_id, device_name, api_key, status, created_by)
VALUES ('LOCAL-KIOSK-01', 'Default Kiosk', 'local_api_key_123456', 'active', 'system')
ON DUPLICATE KEY UPDATE
  device_name = VALUES(device_name),
  status = 'active',
  revoked_at = NULL;
