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 {
191191 ) ;
192192 block_store
193193 . update_db_version ( )
194- . expect ( "Updating `db_version` works " ) ;
194+ . expect ( "Updating `db_version` should work " ) ;
195195
196196 Arc :: new ( DieselStore :: new ( subgraph_store, block_store) )
197197 }
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ use self::primary::Chain;
3333#[ cfg( debug_assertions) ]
3434pub const FAKE_NETWORK_SHARED : & str = "fake_network_shared" ;
3535
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+
3640/// The status of a chain: whether we can only read from the chain, or
3741/// whether it is ok to ingest from it, too
3842#[ derive( Copy , Clone ) ]
@@ -531,6 +535,18 @@ impl BlockStore {
531535 . set ( dbv:: version. eq ( 3 ) )
532536 . execute ( & mut conn) ?;
533537 } ;
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+ }
534550 Ok ( ( ) )
535551 }
536552
You can’t perform that action at this time.
0 commit comments