@@ -12,7 +12,7 @@ use tokio::time::Duration;
12
12
use mithril_common:: certificate_chain:: MithrilCertificateVerifier ;
13
13
use mithril_common:: chain_observer:: { CardanoCliRunner , ChainObserver } ;
14
14
use mithril_common:: crypto_helper:: ProtocolGenesisVerifier ;
15
- use mithril_common:: database:: { ApplicationNodeType , ApplicationVersionChecker } ;
15
+ use mithril_common:: database:: { ApplicationNodeType , DatabaseVersionChecker } ;
16
16
use mithril_common:: digesters:: { CardanoImmutableDigester , ImmutableFileSystemObserver } ;
17
17
use mithril_common:: entities:: { Epoch , HexEncodedGenesisSecretKey } ;
18
18
use mithril_common:: store:: adapter:: SQLiteAdapter ;
@@ -37,12 +37,7 @@ fn setup_genesis_dependencies(
37
37
config : & GenesisConfiguration ,
38
38
) -> Result < GenesisToolsDependency , Box < dyn std:: error:: Error > > {
39
39
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 ( ) ) ?;
46
41
47
42
let chain_observer = Arc :: new (
48
43
mithril_common:: chain_observer:: CardanoCliChainObserver :: new ( Box :: new (
@@ -143,6 +138,17 @@ async fn do_first_launch_initialization_if_needed(
143
138
Ok ( ( ) )
144
139
}
145
140
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
+
146
152
/// Mithril Aggregator Node
147
153
#[ derive( Parser , Debug , Clone ) ]
148
154
#[ command( version) ]
@@ -304,12 +310,7 @@ impl ServeCommand {
304
310
. map_err ( |e| format ! ( "configuration deserialize error: {}" , e) ) ?;
305
311
debug ! ( "SERVE command" ; "config" => format!( "{:?}" , config) ) ;
306
312
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 ( ) ) ?;
313
314
314
315
// Init dependencies
315
316
let snapshot_store = config. build_snapshot_store ( ) ?;
0 commit comments