File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ impl StoreBuilder {
191
191
) ;
192
192
block_store
193
193
. update_db_version ( )
194
- . expect ( "Updating `db_version` works " ) ;
194
+ . expect ( "Updating `db_version` should work " ) ;
195
195
196
196
Arc :: new ( DieselStore :: new ( subgraph_store, block_store) )
197
197
}
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ use self::primary::Chain;
33
33
#[ cfg( debug_assertions) ]
34
34
pub const FAKE_NETWORK_SHARED : & str = "fake_network_shared" ;
35
35
36
+ // Highest version of the database that the executable supports.
37
+ // To be incremented on each breaking change to the database.
38
+ const SUPPORTED_DB_VERSION : i64 = 3 ;
39
+
36
40
/// The status of a chain: whether we can only read from the chain, or
37
41
/// whether it is ok to ingest from it, too
38
42
#[ derive( Copy , Clone ) ]
@@ -531,6 +535,18 @@ impl BlockStore {
531
535
. set ( dbv:: version. eq ( 3 ) )
532
536
. execute ( & mut conn) ?;
533
537
} ;
538
+ if version < SUPPORTED_DB_VERSION {
539
+ // Bump it to make sure that all executables are working with the same DB format
540
+ diesel:: update ( dbv:: table)
541
+ . set ( dbv:: version. eq ( SUPPORTED_DB_VERSION ) )
542
+ . execute ( & mut conn) ?;
543
+ } ;
544
+ if version > SUPPORTED_DB_VERSION {
545
+ panic ! (
546
+ "The executable is too old and doesn't support the database version: {}" ,
547
+ version
548
+ )
549
+ }
534
550
Ok ( ( ) )
535
551
}
536
552
You can’t perform that action at this time.
0 commit comments