Why not keep the replaced ones in the batteries table? A battery is a battery after all.
Just put a column (boolean) in there replaced and add a nullable replaced_with_id in there, linking back to batteries.id
There is no need to create a new table for that.
In that case, replacing the battery would be:
- Add a new battery for this customer to the table
- flip the replaced boolean on the current battery row to 1
- update the old battery with replaced_with_id = {old_id}
otherwise, you'd be adding a battery to the new table, then replicating the old battery from 1 table to another (also updating it's new_battery_id), and deleting the old row.