YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: handle migration checksum mismatch from modified fps migration
Louis Beaumont666ae0d8848e
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rsindex b8293722b..4732717e2 100644--- a/crates/screenpipe-db/src/db.rs+++ b/crates/screenpipe-db/src/db.rs@@ -152,8 +152,51 @@ impl DatabaseManager {migrator.set_ignore_missing(true);match migrator.run(pool).await {Ok(_) => Ok(()),- Err(e) => Err(e.into()),+ Err(e) => {+ let err_str = e.to_string();+ // Handle checksum mismatch from modified migrations.+ // This can happen when a migration file was changed after being applied+ // (e.g., the fps migration was modified between v0.3.130 and v0.3.131).+ // Fix: update the stored checksum to match the current file, then retry.+ if err_str.contains("was previously applied but has been modified") {+ tracing::warn!(+ "Migration checksum mismatch detected: {}. Updating checksums and retrying...",+ err_str+ );+ Self::fix_migration_checksums(pool, &migrator).await?;+ // Retry after fixing checksums+ migrator.run(pool).await.map_err(|e| e.into())+ } else {+ Err(e.into())+ }+ }+ }+ }++ /// Fix checksum mismatches by updating stored checksums to match current migration files.+ /// This is needed when a migration file was modified after being applied to the DB+ /// (which happened with the fps migration between v0.3.130 and v0.3.131).+ async fn fix_migration_checksums(+ pool: &SqlitePool,+ migrator: &sqlx::migrate::Migrator,+ ) -> Result<(), sqlx::Error> {+ for migration in migrator.iter() {+ if migration.migration_type.is_down_migration() {+ continue;+ }+ // Update the checksum for any previously-applied migration to match the current file+ let version = migration.version;+ let checksum_bytes: &[u8] = &migration.checksum;+ sqlx::query(+ "UPDATE _sqlx_migrations SET checksum = ? WHERE version = ?"+ )+ .bind(checksum_bytes)+ .bind(version)+ .execute(pool)+ .await?;}+ tracing::info!("Migration checksums updated successfully");+ Ok(())}/// Acquire a connection with `BEGIN IMMEDIATE` and retry on SQLITE_BUSY variants.diff --git a/crates/screenpipe-db/src/migrations/20260207100000_backfill_fps_defaults.sql b/crates/screenpipe-db/src/migrations/20260207100000_backfill_fps_defaults.sqlnew file mode 100644index 000000000..3e66bcd20--- /dev/null+++ b/crates/screenpipe-db/src/migrations/20260207100000_backfill_fps_defaults.sql@@ -0,0 +1,4 @@+-- Backfill NULL fps values for users who got the nullable version of the fps migration (v0.3.130).+-- The column was later changed to NOT NULL DEFAULT 0.5 (v0.3.131+), but users who ran v0.3.130+-- have NULL values for pre-existing rows. This ensures consistent data regardless of upgrade path.+UPDATE video_chunks SET fps = 0.5 WHERE fps IS NULL;