mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Try to fix pkey migration
This commit is contained in:
parent
02d4235abd
commit
a52fe9fbc6
1 changed files with 7 additions and 3 deletions
|
|
@ -1,10 +1,14 @@
|
|||
import { type Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<unknown>): Promise<void> {
|
||||
try {
|
||||
const result = await sql<{ count: number }>`
|
||||
SELECT COUNT(*) as count
|
||||
FROM pg_indexes
|
||||
WHERE indexname = 'nostr_events_new_pkey'
|
||||
`.execute(db);
|
||||
|
||||
if (result.rows[0].count > 0) {
|
||||
await sql`ALTER INDEX nostr_events_new_pkey RENAME TO nostr_events_pkey;`.execute(db);
|
||||
} catch {
|
||||
// all good
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue