Skip to content

Commit 1508c4d

Browse files
committed
store: Map more tables across shards
This now includes ethereum_networks, copy_state, copy_table_state, and subgraph_features. We no longer map subgraph, subgraph_version, and subgraph_deployment_assignment into the shard_* namespace since these tables are only maintained in the primary, and are mapped in the primary_public namespace.
1 parent eacdc22 commit 1508c4d

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

store/postgres/src/connection_pool.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,31 @@ impl ForeignServer {
206206
/// Map the `subgraphs` schema from the foreign server `self` into the
207207
/// database accessible through `conn`
208208
fn map_metadata(&self, conn: &mut PgConnection) -> Result<(), StoreError> {
209+
const MAP_TABLES: [(&str, &[&str]); 2] = [
210+
("public", &["ethereum_networks"]),
211+
(
212+
"subgraphs",
213+
&[
214+
"copy_state",
215+
"copy_table_state",
216+
"dynamic_ethereum_contract_data_source",
217+
"subgraph_deployment",
218+
"subgraph_error",
219+
"subgraph_features",
220+
"subgraph_manifest",
221+
"table_stats",
222+
],
223+
),
224+
];
209225
let nsp = Self::metadata_schema(&self.shard);
210226
catalog::recreate_schema(conn, &nsp)?;
211227
let mut query = String::new();
212-
for table_name in [
213-
"subgraph_error",
214-
"dynamic_ethereum_contract_data_source",
215-
"table_stats",
216-
"subgraph_deployment_assignment",
217-
"subgraph",
218-
"subgraph_version",
219-
"subgraph_deployment",
220-
"subgraph_manifest",
221-
] {
222-
let create_stmt =
223-
catalog::create_foreign_table(conn, "subgraphs", table_name, &nsp, &self.name)?;
224-
write!(query, "{}", create_stmt)?;
228+
for (src_nsp, src_tables) in MAP_TABLES {
229+
for src_table in src_tables {
230+
let create_stmt =
231+
catalog::create_foreign_table(conn, src_nsp, src_table, &nsp, &self.name)?;
232+
write!(query, "{}", create_stmt)?;
233+
}
225234
}
226235
Ok(conn.batch_execute(&query)?)
227236
}

0 commit comments

Comments
 (0)