Use a transaction when creating an artifact.

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
If `err` is not a `unique_violation` it isn't being checked now, you could add an `} else if err != nil {` to make things clearer.