Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node/src/store_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl StoreBuilder {
);
block_store
.update_db_version()
.expect("Updating `db_version` works");
.expect("Updating `db_version` should work");

Arc::new(DieselStore::new(subgraph_store, block_store))
}
Expand Down
16 changes: 16 additions & 0 deletions store/postgres/src/block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ use self::primary::Chain;
#[cfg(debug_assertions)]
pub const FAKE_NETWORK_SHARED: &str = "fake_network_shared";

// Highest version of the database that the executable supports.
// To be incremented on each breaking change to the database.
const SUPPORTED_DB_VERSION: i64 = 3;

/// The status of a chain: whether we can only read from the chain, or
/// whether it is ok to ingest from it, too
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -531,6 +535,18 @@ impl BlockStore {
.set(dbv::version.eq(3))
.execute(&mut conn)?;
};
if version < SUPPORTED_DB_VERSION {
// Bump it to make sure that all executables are working with the same DB format
diesel::update(dbv::table)
.set(dbv::version.eq(SUPPORTED_DB_VERSION))
.execute(&mut conn)?;
};
if version > SUPPORTED_DB_VERSION {
panic!(
"The executable is too old and doesn't support the database version: {}",
version
)
}
Ok(())
}

Expand Down
Loading