IoT Device Identity That Survives Hardware Swaps
Sep 17, 2026 · 4 min read
Keep a location’s history intact when hardware changes: logical identity, physical units and a safe migration order.

In IoT device lifecycle management, customers think of a device as a spot on their map, while the circuit board bolted to it can be swapped out. When history follows the board instead of the spot, routine hardware swaps can split a location's history in two, and the cleanup that looks obvious can do more damage than the original bug.
On a recent engagement, I built a lifecycle model that separates a location’s identity from its replaceable hardware. The work combined data-model changes with migration planning and a setup flow that makes replacement intent explicit.
- Problem
- Hardware replacement needed to preserve a location’s continuous history.
- What I changed
- Separate logical and physical identity, shared lifecycle operations, a readers-first migration and an explicit setup choice.
- Result
- The lifecycle model is in production.
Where the histories were splitting
The platform manages replaceable IoT units. A location can use several units over time, and a refurbished unit can later belong to another account. Logical identity must preserve location history without joining unrelated accounts through reused hardware.
An audit log of every device change
I added a database-level lineage log to record identity and lifecycle changes. Recording changes at the database boundary covers every writer.
- Setup. A row when a device is first created, with its starting state.
- Activation state. A row for every state change, from provisioned to activated to retired.
- Customer account and unit. A row whenever a device moves to another customer's account, which is how a unit gets dispatched to a customer or comes back from the field, and whenever its hardware ID changes.
The triggers run inside the database, so every writer is covered, from admin tools to one-off scripts, and none of them has to remember to log.
CREATE TRIGGER trg_device_lineage ON devices AFTER UPDATE AS
INSERT INTO device_lineage (device_id, old_state, new_state, old_account_id, new_account_id,
old_hardware_id, new_hardware_id, changed_at)
SELECT d.id, d.state, i.state, d.account_id, i.account_id, d.hardware_id, i.hardware_id, SYSUTCDATETIME()
FROM inserted i JOIN deleted d ON d.id = i.id
WHERE d.state IS DISTINCT FROM i.state
OR d.account_id IS DISTINCT FROM i.account_id
OR d.hardware_id IS DISTINCT FROM i.hardware_id;The lineage log supports diagnosis and migration checks by preserving the sequence of identity changes.
Audit before cleanup
Before merging records, check every store and lookup that resolves an identity. Similar hardware identifiers do not establish that two records belong to the same location or account. Preserve historical access boundaries when hardware is reused.
Illustrative identities, not customer records: one location uses three units, and one unit later moves to another account.
A new location ID on every swap
In this illustrative example, a new logical identity would split one location’s history.
Join history on the hardware ID
A reused unit can span unrelated accounts. Hardware alone cannot establish a customer’s right to historical data.
Join history on the location
A stable logical identity keeps location history continuous while hardware bindings change. Account authorization remains a separate check.
A reusable IoT device lifecycle model
Two identities. The logical device is a location with one continuous history. The physical unit is a circuit board that can belong to several locations over its life. The device record holds the current binding, and the history table holds the lineage.
Shared lifecycle operations. Keep replacement, temporary removal, reactivation and refurbishment rules in one place. Validate transitions and preserve the distinction between a location and its current unit. A uniqueness constraint can affect the intermediate steps of a swap. Design the transaction and statements around when the database checks the constraint, then test the complete operation.
The rollout order matters. Update readers to accept the new representation before changing data or writers. Add stricter constraints only after the data satisfies them.
Schematic migration sequence. Coordinate readers, data, writers and constraints; choose recovery and concurrency controls for the system.
Out of order, it breaks
Writers before readers
A new representation can break consumers that understand only the old shape.
Migration without coordination
Concurrent legacy writes can recreate the representation being removed.
Constraints before verification
A stricter constraint cannot be enforced while existing data violates it.
An explicit choice at setup. Ask whether a unit is going to a new location or replacing an existing one. If the information needed to make that choice is unavailable, stop rather than silently creating a new identity.
Results
The lifecycle model is in production. The migration preserves logical identity while allowing hardware bindings to change.
What I'd tell another team
Those odd-looking records were how the system remembered requirements nobody had written down.
- Audit before you clean. Check every store that reads the data, and every lookup that resolves it.
- Separate logical identity from physical identity. Reused hardware must not join the histories of unrelated accounts.
- Readers first, uniqueness last. Keep old and new representations compatible during the migration, then enforce the new constraint.
- Log changes where they happen. A trigger-written audit log covers every writer, including the ones nobody remembers, and it's there when you need to reconstruct what happened.
- Prevent mistakes where the context is. Ask the person performing setup whether the hardware is replacing an existing unit.
When this is the wrong model: if history belongs to the unit, as in a warranty or repair workflow, physical identity should lead. For a migration, choose a concurrency strategy that prevents old writers from recreating the data being removed.