Merge branch 'main' into 'use-postgres-js'

# Conflicts:
#   deno.json
#   src/db/adapters/DittoPostgres.ts
This commit is contained in:
Siddharth Singh
2024-07-06 12:03:21 +00:00
20 changed files with 493 additions and 60 deletions

View File

@@ -7,6 +7,7 @@ export interface DittoTables {
author_stats: AuthorStatsRow;
event_stats: EventStatsRow;
pubkey_domains: PubkeyDomainRow;
event_zaps: EventZapRow;
}
interface AuthorStatsRow {
@@ -69,3 +70,11 @@ interface PubkeyDomainRow {
domain: string;
last_updated_at: number;
}
interface EventZapRow {
receipt_id: string;
target_event_id: string;
sender_pubkey: string;
amount_millisats: number;
comment: string;
}

View File

@@ -0,0 +1,32 @@
import { Kysely } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.createTable('event_zaps')
.addColumn('receipt_id', 'text', (col) => col.primaryKey())
.addColumn('target_event_id', 'text', (col) => col.notNull())
.addColumn('sender_pubkey', 'text', (col) => col.notNull())
.addColumn('amount_millisats', 'integer', (col) => col.notNull())
.addColumn('comment', 'text', (col) => col.notNull())
.execute();
await db.schema
.createIndex('idx_event_zaps_amount_millisats')
.on('event_zaps')
.column('amount_millisats')
.ifNotExists()
.execute();
await db.schema
.createIndex('idx_event_zaps_target_event_id')
.on('event_zaps')
.column('target_event_id')
.ifNotExists()
.execute();
}
export async function down(db: Kysely<any>): Promise<void> {
await db.schema.dropIndex('idx_event_zaps_amount_millisats').ifExists().execute();
await db.schema.dropIndex('idx_event_zaps_target_event_id').ifExists().execute();
await db.schema.dropTable('event_zaps').execute();
}