Skip to content

Commit e81cea8

Browse files
authored
Get schema version by action id index (#6829)
1 parent 5fa121f commit e81cea8

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.changeset/afraid-years-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': patch
3+
---
4+
5+
Add pg index for getSchemaVersionByActionId to improve lookup performance
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { type MigrationExecutor } from '../pg-migrator';
2+
3+
/**
4+
* Adds an index specifically for getSchemaVersionByActionId.
5+
*/
6+
export default {
7+
name: '2025.05.28T00-00-00.schema-log-by-ids.ts',
8+
noTransaction: true,
9+
run: ({ sql }) => [
10+
{
11+
name: 'index schema_log_by_ids',
12+
query: sql`
13+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "schema_log_by_ids" ON "schema_log"(
14+
"project_id"
15+
, "target_id"
16+
, "commit"
17+
)
18+
`,
19+
},
20+
],
21+
} satisfies MigrationExecutor;

packages/migrations/src/run-pg-migrations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,6 @@ export const runPGMigrations = async (args: { slonik: DatabasePool; runTo?: stri
166166
await import('./actions/2025.05.15T00-00-00.redundant-indices'),
167167
await import('./actions/2025.05.15T00-00-00.contracts-foreign-key-constraint-fix'),
168168
await import('./actions/2025.05.15T00-00-01.organization-member-pagination'),
169+
await import('./actions/2025.05.28T00-00-00.schema-log-by-ids'),
169170
],
170171
});

0 commit comments

Comments
 (0)