MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / migrate

Method migrate

crates/chat-cli/src/database/mod.rs:431–458  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

429 // Private functions. Do not expose.
430
431 fn migrate(self) -> Result<Self, DatabaseError> {
432 let mut conn = self.pool.get()?;
433 let transaction = conn.transaction()?;
434
435 let max_version = max_migration_version(&transaction);
436
437 for (version, migration) in MIGRATIONS.iter().enumerate() {
438 if has_migration(&transaction, version, max_version)? {
439 continue;
440 }
441
442 // execute the migration
443 transaction.execute_batch(migration.sql)?;
444
445 info!(%version, name =% migration.name, "Applying migration");
446
447 // insert the migration entry
448 transaction.execute(
449 "INSERT INTO migrations (version, migration_time) VALUES (?1, strftime('%s', 'now'));",
450 params![version],
451 )?;
452 }
453
454 // commit the transaction
455 transaction.commit()?;
456
457 Ok(self)
458 }
459
460 fn get_entry<T: FromSql>(&self, table: Table, key: impl AsRef<str>) -> Result<Option<T>, DatabaseError> {
461 let conn = self.pool.get()?;

Callers 1

newMethod · 0.80

Calls 4

max_migration_versionFunction · 0.85
has_migrationFunction · 0.85
getMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected