-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve indexing for chat.bsky.moderation.getMessageContext (#3520)
* Improve indexing for chat.bsky.moderation.getMessageContext * tidy
- Loading branch information
1 parent
eb83ae1
commit 20e57ba
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/ozone": patch | ||
--- | ||
|
||
Improve indexing for "chat.bsky.moderation.getMessageContext" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/ozone/src/db/migrations/20250211T132135150Z-moderation-event-message-partial-idx.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Kysely, sql } from 'kysely' | ||
|
||
// support lookup for chat.bsky.moderation.getMessageContext | ||
|
||
export async function up(db: Kysely<unknown>): Promise<void> { | ||
// @NOTE: These queries should be run with the "CONCURRENTLY" option in | ||
// production to avoid locking the table. This is not supported by Kysely. | ||
await db.schema.dropIndex('moderation_event_message_id_index').execute() | ||
await db.schema | ||
.createIndex('moderation_event_message_id_idx') | ||
.on('moderation_event') | ||
// https://github.com/kysely-org/kysely/issues/302 | ||
.expression( | ||
sql`"subjectMessageId") WHERE ("subjectMessageId" IS NOT NULL AND "action" = 'tools.ozone.moderation.defs#modEventReport'`, | ||
) | ||
.execute() | ||
} | ||
|
||
export async function down(db: Kysely<unknown>): Promise<void> { | ||
await db.schema.dropIndex('moderation_event_message_id_idx').execute() | ||
await db.schema | ||
.createIndex('moderation_event_message_id_index') | ||
.on('moderation_event') | ||
.column('subjectMessageId') | ||
.execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters