radicle/cob/db: Add index for issues and patches
To improve query performance for issues and patches, add a composite index on "repo" and "id" to the SQLite database schema via a migration.
This commit is contained in:
parent
990e22acff
commit
5741bafa3b
|
|
@ -28,6 +28,7 @@ const DB_WRITE_TIMEOUT: time::Duration = time::Duration::from_secs(6);
|
||||||
const MIGRATIONS: &[Migration] = &[
|
const MIGRATIONS: &[Migration] = &[
|
||||||
Migration::Sql(include_str!("cache/migrations/1.sql")),
|
Migration::Sql(include_str!("cache/migrations/1.sql")),
|
||||||
Migration::Native(migrations::_2::run),
|
Migration::Native(migrations::_2::run),
|
||||||
|
Migration::Sql(include_str!("cache/migrations/3.sql")),
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Function signature for native migrations.
|
/// Function signature for native migrations.
|
||||||
|
|
@ -466,10 +467,13 @@ mod tests {
|
||||||
assert_eq!(db.migrate_to(2, migrate::ignore).unwrap(), 2); // 1 -> 2
|
assert_eq!(db.migrate_to(2, migrate::ignore).unwrap(), 2); // 1 -> 2
|
||||||
assert_eq!(db.version().unwrap(), 2);
|
assert_eq!(db.version().unwrap(), 2);
|
||||||
|
|
||||||
assert_eq!(db.migrate_to(1, migrate::ignore).unwrap(), 2); // No-op.
|
assert_eq!(db.migrate_to(3, migrate::ignore).unwrap(), 3); // 2 -> 3
|
||||||
assert_eq!(db.version().unwrap(), 2);
|
assert_eq!(db.version().unwrap(), 3);
|
||||||
|
|
||||||
assert_eq!(db.migrate_to(99, migrate::ignore).unwrap(), 2); // No-op.
|
assert_eq!(db.migrate_to(1, migrate::ignore).unwrap(), 3); // No-op.
|
||||||
assert_eq!(db.version().unwrap(), 2);
|
assert_eq!(db.version().unwrap(), 3);
|
||||||
|
|
||||||
|
assert_eq!(db.migrate_to(99, migrate::ignore).unwrap(), 3); // No-op.
|
||||||
|
assert_eq!(db.version().unwrap(), 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
create index if not exists 'ix_issues_repo_id' on 'issues' (repo, id);
|
||||||
|
create index if not exists 'ix_patches_repo_id' on 'patches' (repo, id);
|
||||||
Loading…
Reference in New Issue