author_stats: add index on followers_count

This commit is contained in:
Alex Gleason 2024-09-20 09:16:09 -05:00
parent ab727c3940
commit c582b1c520
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -0,0 +1,17 @@
import { Kysely } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.createIndex('author_stats_followers_count_idx')
.ifNotExists()
.on('author_stats')
.column('followers_count desc')
.execute();
// This index should have never been added, because pubkey is the primary key.
await db.schema.dropIndex('idx_author_stats_pubkey').ifExists().execute();
}
export async function down(db: Kysely<any>): Promise<void> {
await db.schema.dropIndex('author_stats_followers_count_idx').ifExists().execute();
}