Skip to content

Commit

Permalink
Add missing record cursor indices (bluesky-social#1693)
Browse files Browse the repository at this point in the history
add missing record cursor inddices
  • Loading branch information
dholms committed Sep 29, 2023
1 parent feb994a commit cef38e3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Kysely } from 'kysely'

export async function up(db: Kysely<unknown>): Promise<void> {
await db.schema
.createIndex('like_creator_cursor_idx')
.on('like')
.columns(['creator', 'sortAt', 'cid'])
.execute()
await db.schema
.createIndex('follow_creator_cursor_idx')
.on('follow')
.columns(['creator', 'sortAt', 'cid'])
.execute()
await db.schema
.createIndex('follow_subject_cursor_idx')
.on('follow')
.columns(['subjectDid', 'sortAt', 'cid'])
.execute()

// drop old indices that are superceded by these
await db.schema.dropIndex('like_creator_idx').execute()
await db.schema.dropIndex('follow_subjectdid_idx').execute()
}

export async function down(db: Kysely<unknown>): Promise<void> {
await db.schema
.createIndex('like_creator_idx')
.on('like')
.column('creator')
.execute()
await db.schema
.createIndex('follow_subjectdid_idx')
.on('follow')
.column('subjectDid')
.execute()

await db.schema.dropIndex('like_creator_cursor_idx').execute()
await db.schema.dropIndex('follow_creator_cursor_idx').execute()
await db.schema.dropIndex('follow_subject_cursor_idx').execute()
}
1 change: 1 addition & 0 deletions packages/bsky/src/db/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export * as _20230830T205507322Z from './20230830T205507322Z-suggested-feeds'
export * as _20230904T211011773Z from './20230904T211011773Z-block-lists'
export * as _20230906T222220386Z from './20230906T222220386Z-thread-gating'
export * as _20230920T213858047Z from './20230920T213858047Z-add-tags-to-post'
export * as _20230929T192920807Z from './20230929T192920807Z-record-cursor-indexes'

0 comments on commit cef38e3

Please sign in to comment.