delete_device() keeps primary key of device to prevent reuse.
just set it hostid = 0 to make it belong to no host.
get_all_devices() returns devices which hostid > 0
to avoid interactions with deleted devices.