Improve duplicate serial number detection
Duplicated serial number can be detected by failed SQL INSERT
with UNIQUE
constraint on sn
field.
It is more reliable and straight-forward solution than the ugly get_unique_serial_number
method where a race-condition is also possible (in case of multi process/thread implementation).