aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-scripts/src/store.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/atuin-scripts/src/store.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/atuin-scripts/src/store.rs b/crates/atuin-scripts/src/store.rs
index ba7a1ca1..e70f6909 100644
--- a/crates/atuin-scripts/src/store.rs
+++ b/crates/atuin-scripts/src/store.rs
@@ -91,7 +91,12 @@ impl ScriptStore {
}
pub async fn build(&self, database: Database) -> Result<()> {
- // Get all the scripts from the database - they are already sorted by timestamp
+ // Clear existing data before replaying all records from the store.
+ // Without this, stale rows can cause unique constraint violations
+ // when records are replayed (eg name conflicts from renamed scripts).
+ database.clear().await?;
+
+ // Get all the scripts from the store - they are already sorted by timestamp
let scripts = self.scripts().await?;
for script in scripts {