INNER CODE UNIT · Rust
try_apply_migrations
aannoo/hcom · src/db/mod.rs:738
fn try_apply_migrations(&self, old_version: i32) -> Result<bool> {
if old_version <= 0 || old_version >= SCHEMA_VERSION {
return Ok(false);
}
let tx = self.conn.unchecked_transaction()?;
for next_version in (old_version + 1)..=SCHEMA_VERSION {
if next_version == 17 {
let has_launch_context = tx
.prepare("PRAGMA table_info(instances)")?
.query_map([], |row| row.get::<_, String>(1))?
.filter_map(|r| r.ok())
.any(|col| col == "launch_context");
if !has_launch_context {
tx.execute(
"ALTER TABLE instances ADD COLUMN launch_context TEXT DEFAULT ''",
[],
)?;
}