Private
Public Access
1
0

adds the ability to clear db

This commit is contained in:
2025-05-01 01:08:13 -07:00
parent fd4c43d585
commit 13a78ccd47
6 changed files with 53 additions and 0 deletions

View File

@@ -222,6 +222,18 @@ impl<'a> Repository<'a> {
Ok(message_record.map(|r| r.into()))
}
pub fn delete_all_conversations(&mut self) -> Result<()> {
use crate::schema::conversations::dsl::*;
diesel::delete(conversations).execute(self.connection)?;
Ok(())
}
pub fn delete_all_messages(&mut self) -> Result<()> {
use crate::schema::messages::dsl::*;
diesel::delete(messages).execute(self.connection)?;
Ok(())
}
// Helper function to get the last inserted row ID
// This is a workaround since the Sqlite backend doesn't support `RETURNING`
// Huge caveat with this is that it depends on whatever the last insert was, prevents concurrent inserts.