summaryrefslogtreecommitdiffstats
path: root/src/db/models/submit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/models/submit.rs')
-rw-r--r--src/db/models/submit.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/db/models/submit.rs b/src/db/models/submit.rs
index 154ed1b..61788ad 100644
--- a/src/db/models/submit.rs
+++ b/src/db/models/submit.rs
@@ -61,16 +61,18 @@ impl Submit {
repo_hash_id: repo_hash.id,
};
- diesel::insert_into(submits::table)
- .values(&new_submit)
+ database_connection.transaction::<_, Error, _>(|| {
+ diesel::insert_into(submits::table)
+ .values(&new_submit)
- // required because if we re-use the staging store, we do not create a new UUID but re-use the old one
- .on_conflict_do_nothing()
+ // required because if we re-use the staging store, we do not create a new UUID but re-use the old one
+ .on_conflict_do_nothing()
- .execute(database_connection)
- .context("Inserting new submit into submits table")?;
+ .execute(database_connection)
+ .context("Inserting new submit into submits table")?;
- Self::with_id(database_connection, submit_id)
+ Self::with_id(database_connection, submit_id)
+ })
}
pub fn with_id(database_connection: &PgConnection, submit_id: &::uuid::Uuid) -> Result<Submit> {