Skip to content

Commit 8c5557c

Browse files
authored
Merge pull request #611 from input-output-hk/greg/600/database_migration
Greg/600/database migration
2 parents 206613d + 19e0a35 commit 8c5557c

File tree

6 files changed

+452
-189
lines changed

6 files changed

+452
-189
lines changed

.github/workflows/scripts/edit-cargo-toml-version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def append_label_to_cargo_toml_version(cargo_toml_path, label: str, dry_run: boo
2020
print("No package section (probably a workspace file), skipping this Cargo.toml")
2121
return
2222

23-
new_version = f"{cargo_toml['package']['version'].split('-', 1)[0]}-{label}"
23+
new_version = f"{cargo_toml['package']['version'].split('+', 1)[0]}+{label}"
2424
print(f"{cargo_toml_path} new version: {new_version}")
2525

2626
if not dry_run:

mithril-aggregator/src/command_args.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tokio::time::Duration;
1212
use mithril_common::certificate_chain::MithrilCertificateVerifier;
1313
use mithril_common::chain_observer::{CardanoCliRunner, ChainObserver};
1414
use mithril_common::crypto_helper::ProtocolGenesisVerifier;
15-
use mithril_common::database::{ApplicationNodeType, ApplicationVersionChecker};
15+
use mithril_common::database::{ApplicationNodeType, DatabaseVersionChecker};
1616
use mithril_common::digesters::{CardanoImmutableDigester, ImmutableFileSystemObserver};
1717
use mithril_common::entities::{Epoch, HexEncodedGenesisSecretKey};
1818
use mithril_common::store::adapter::SQLiteAdapter;
@@ -37,12 +37,7 @@ fn setup_genesis_dependencies(
3737
config: &GenesisConfiguration,
3838
) -> Result<GenesisToolsDependency, Box<dyn std::error::Error>> {
3939
let sqlite_db_path = Some(config.get_sqlite_file());
40-
ApplicationVersionChecker::new(
41-
slog_scope::logger(),
42-
ApplicationNodeType::Aggregator,
43-
config.get_sqlite_file(),
44-
)
45-
.check(env!("CARGO_PKG_VERSION"))?;
40+
check_database_migration(config.get_sqlite_file())?;
4641

4742
let chain_observer = Arc::new(
4843
mithril_common::chain_observer::CardanoCliChainObserver::new(Box::new(
@@ -143,6 +138,17 @@ async fn do_first_launch_initialization_if_needed(
143138
Ok(())
144139
}
145140

141+
/// Database version checker.
142+
/// This is the place where migrations are to be registered.
143+
fn check_database_migration(sql_file_path: PathBuf) -> Result<(), Box<dyn Error>> {
144+
DatabaseVersionChecker::new(
145+
slog_scope::logger(),
146+
ApplicationNodeType::Aggregator,
147+
sql_file_path,
148+
)
149+
.apply()
150+
}
151+
146152
/// Mithril Aggregator Node
147153
#[derive(Parser, Debug, Clone)]
148154
#[command(version)]
@@ -304,12 +310,7 @@ impl ServeCommand {
304310
.map_err(|e| format!("configuration deserialize error: {}", e))?;
305311
debug!("SERVE command"; "config" => format!("{:?}", config));
306312
let sqlite_db_path = Some(config.get_sqlite_file());
307-
ApplicationVersionChecker::new(
308-
slog_scope::logger(),
309-
ApplicationNodeType::Aggregator,
310-
config.get_sqlite_file(),
311-
)
312-
.check(env!("CARGO_PKG_VERSION"))?;
313+
check_database_migration(config.get_sqlite_file())?;
313314

314315
// Init dependencies
315316
let snapshot_store = config.build_snapshot_store()?;

0 commit comments

Comments
 (0)