Skip to content

Commit 4b75bac

Browse files
author
Zoran Cvetkov
committed
store: prepare for breaking changes of the database
1 parent 1d29605 commit 4b75bac

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

node/src/store_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- we don't rename the column name back in order to avoid the accidental downgrade of the binary
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table public.db_version
2+
rename column db_version to database_version;

store/postgres/src/block_store.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ use self::primary::Chain;
3333
#[cfg(debug_assertions)]
3434
pub const FAKE_NETWORK_SHARED: &str = "fake_network_shared";
3535

36+
// Highest version of the database that the executable supports
37+
const SUPPORTED_DB_VERSION: i64 = 3;
38+
3639
/// The status of a chain: whether we can only read from the chain, or
3740
/// whether it is ok to ingest from it, too
3841
#[derive(Copy, Clone)]
@@ -531,6 +534,12 @@ impl BlockStore {
531534
.set(dbv::version.eq(3))
532535
.execute(&mut conn)?;
533536
};
537+
if version > SUPPORTED_DB_VERSION {
538+
panic!(
539+
"The executable is too old and doesn't support the database version: {}",
540+
version
541+
)
542+
}
534543
Ok(())
535544
}
536545

store/postgres/src/primary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ table! {
186186

187187
table! {
188188
public.db_version(version) {
189-
#[sql_name = "db_version"]
189+
#[sql_name = "database_version"]
190190
version -> BigInt,
191191
}
192192
}

0 commit comments

Comments
 (0)