diff --git a/packages/db/DittoDB.ts b/packages/db/DittoDB.ts index e18242cd..f3442808 100644 --- a/packages/db/DittoDB.ts +++ b/packages/db/DittoDB.ts @@ -4,8 +4,6 @@ import path from 'node:path'; import { logi } from '@soapbox/logi'; import { FileMigrationProvider, type Kysely, Migrator } from 'kysely'; -import { errorJson } from '@/utils/log.ts'; - import { DittoPglite } from './adapters/DittoPglite.ts'; import { DittoPostgres } from './adapters/DittoPostgres.ts'; @@ -51,7 +49,7 @@ export class DittoDB { msg: 'Migration failed.', state: 'failed', results: results as unknown as JsonValue, - error: errorJson(error), + error: error instanceof Error ? error : null, }); Deno.exit(1); } else { diff --git a/packages/db/migrations/037_auth_tokens.ts b/packages/db/migrations/037_auth_tokens.ts index 591ff379..f7ac340c 100644 --- a/packages/db/migrations/037_auth_tokens.ts +++ b/packages/db/migrations/037_auth_tokens.ts @@ -1,9 +1,5 @@ import { type Kysely, sql } from 'kysely'; -import { Conf } from '@/config.ts'; -import { aesEncrypt } from '@/utils/aes.ts'; -import { getTokenHash } from '@/utils/auth.ts'; - interface DB { nip46_tokens: { api_token: `token1${string}`; @@ -32,19 +28,6 @@ export async function up(db: Kysely): Promise { .addColumn('created_at', 'timestamp', (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`)) .execute(); - // There are probably not that many tokens in the database yet, so this should be fine. - const tokens = await db.selectFrom('nip46_tokens').selectAll().execute(); - - for (const token of tokens) { - await db.insertInto('auth_tokens').values({ - token_hash: await getTokenHash(token.api_token), - pubkey: token.user_pubkey, - nip46_sk_enc: await aesEncrypt(Conf.seckey, token.server_seckey), - nip46_relays: JSON.parse(token.relays), - created_at: token.connected_at, - }).execute(); - } - await db.schema.dropTable('nip46_tokens').execute(); }