Skip to content

Commit 7a046cc

Browse files
authored
add index creation to migration scripts (#4296)
and remove the one-off `run_non_transactional_migrations`. For existing prod DBs this is a no-op; for fresh DBs the table is empty, so a non-concurrent build is fine. Will add a comment in the next release note about this so anyone using this in prod can also create this index before performing the upgrade.
1 parent f1c8c85 commit 7a046cc

3 files changed

Lines changed: 2 additions & 14 deletions

File tree

nexus/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE INDEX IF NOT EXISTS idx_cdc_batches_flow_name_batch_id_open ON peerdb_stats.cdc_batches (flow_name, batch_id) WHERE end_time IS NULL;

nexus/catalog/src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,6 @@ async fn run_migrations(client: &mut Client) -> anyhow::Result<()> {
151151
migration.version()
152152
);
153153
}
154-
run_non_transactional_migrations(client).await?;
155-
Ok(())
156-
}
157-
158-
async fn run_non_transactional_migrations(client: &Client) -> anyhow::Result<()> {
159-
const STATEMENTS: &[&str] = &[
160-
"CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_cdc_batches_flow_name_batch_id_open ON peerdb_stats.cdc_batches (flow_name, batch_id) WHERE end_time IS NULL",
161-
];
162-
for stmt in STATEMENTS {
163-
client
164-
.batch_execute(stmt)
165-
.await
166-
.with_context(|| format!("Failed to apply non-transactional migration: {stmt}"))?;
167-
}
168154
Ok(())
169155
}
170156

0 commit comments

Comments
 (0)