From e037ccc7ed021d03759b77eb3cda354596e8e857 Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Sat, 4 May 2024 11:57:05 +0530 Subject: [PATCH] add migration for removing pubkey_domains table --- .../migrations/018_remove_pubkey_domains.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/db/migrations/018_remove_pubkey_domains.ts diff --git a/src/db/migrations/018_remove_pubkey_domains.ts b/src/db/migrations/018_remove_pubkey_domains.ts new file mode 100644 index 00000000..7aa1629f --- /dev/null +++ b/src/db/migrations/018_remove_pubkey_domains.ts @@ -0,0 +1,25 @@ +import { Kysely } from 'kysely'; + +export async function up(db: Kysely): Promise { + await db.schema + .dropTable('pubkey_domains') + .ifExists() + .execute(); +} + +export async function down(db: Kysely): Promise { + await db.schema + .createTable('pubkey_domains') + .ifNotExists() + .addColumn('pubkey', 'text', (col) => col.primaryKey()) + .addColumn('domain', 'text', (col) => col.notNull()) + .addColumn('last_updated_at', 'integer', (col) => col.notNull().defaultTo(0)) + .execute(); + + await db.schema + .createIndex('pubkey_domains_domain_index') + .on('pubkey_domains') + .column('domain') + .ifNotExists() + .execute(); +}