Skip to content

Commit 536f4ff

Browse files
committed
store/postgres: Avoid initiating the schema if running against a readonly db
1 parent 258cd72 commit 536f4ff

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

node/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ async fn main() {
561561
subscriptions.clone(),
562562
postgres_conn_pool.clone(),
563563
stores_metrics_registry.clone(),
564+
*EXPERIMENTAL_READONLY_DB,
564565
)),
565566
)
566567
})

store/postgres/src/store.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,15 @@ impl Store {
196196
subscriptions: Option<Arc<SubscriptionManager>>,
197197
pool: Pool<ConnectionManager<PgConnection>>,
198198
registry: Arc<dyn MetricsRegistry>,
199+
readonly_db: bool,
199200
) -> Self {
200201
// Create a store-specific logger
201202
let logger = logger.new(o!("component" => "Store"));
202203

203204
// Create the entities table (if necessary)
204-
initiate_schema(&logger, &pool.get().unwrap(), &pool.get().unwrap());
205+
if !readonly_db {
206+
initiate_schema(&logger, &pool.get().unwrap(), &pool.get().unwrap());
207+
}
205208

206209
// Create the store
207210
let store = StoreInner {

store/test-store/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ lazy_static! {
7676
Some(subscriptions),
7777
postgres_conn_pool,
7878
registry.clone(),
79+
false,
7980
))
8081
})
8182
}).join().unwrap()

0 commit comments

Comments
 (0)