Skip to content

Commit

Permalink
🧹 Cleanup unnecessary index
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit committed Mar 7, 2025
1 parent 8c509f0 commit e8dfd2f
Showing 1 changed file with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
import { Kysely, sql } from 'kysely'
import { Kysely } from 'kysely'

export async function up(db: Kysely<unknown>): Promise<void> {
try {
// Add trigram support, supporting user search.
// Explicitly add to public schema, so the extension can be seen in all schemas.
await sql`create extension if not exists pg_trgm with schema public`.execute(
db,
)
} catch (err: unknown) {
// The "if not exists" isn't bulletproof against races, and we see test suites racing to
// create the extension. So we can just ignore errors indicating the extension already exists.
if (!err?.['detail']?.includes?.('(pg_trgm) already exists')) throw err
}

await db.schema.alterTable('member').addColumn('handle', 'text').execute()
await db.schema
.alterTable('member')
.addColumn('displayName', 'text')
.execute()
await db.schema
.createIndex('member_display_name_idx')
.on('member')
.using('gist')
.expression(sql`"displayName" gist_trgm_ops`)
.execute()
await db.schema
.createIndex('member_handle_idx')
.on('member')
.using('gist')
.expression(sql`"handle" gist_trgm_ops`)
.execute()
}

export async function down(db: Kysely<unknown>): Promise<void> {
Expand Down

0 comments on commit e8dfd2f

Please sign in to comment.