Fix sql  device_id deleted